我正在使用Vite来创建一个新的React + TypeScript项目。
在创建项目后,根目录中有两个TypeScript配置文件:tsconfig.json
和tsconfig.node.json
。以下是每个文件的内容:
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
tsconfig.node.json
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
我们为什么需要两个?
第二个有什么作用?
我能移除第二个吗?
tsconfig.node.json
只是tsconfig.json
的扩展。我认为你不能删除它,因为vite.config.ts
的包含只存在于node.json
中。 - Panomosh