【发布时间】:2022-06-25 21:39:56
【问题描述】:
我正在使用 Vite 创建a new React + TypeScript project。
创建项目后,根文件夹下有两个 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的inlude只存在于node.json中
标签: javascript typescript tsconfig vite