我看到很多人在他们的tsconfig.json
中排除node_modules
。我正在使用具有特定文件夹模式的include
。我还需要排除node_modules
吗?未编译成JS的第三方库(即作为TS包含在我的项目中(怎么样?
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": true,
"declarationDir": "builds",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": true,
"jsx": "preserve",
"jsxFactory": "Vue",
"lib": ["dom", "dom.iterable", "esnext", "scripthost"],
"module": "esnext",
"moduleResolution": "node",
"paths": {
"@/*": ["*"]
},
"sourceMap": true,
"strict": true,
"target": "esnext",
"types": ["jest", "node", "vuetify", "webpack-env"],
"typeRoots": ["node_modules/@types"]
},
"include": [
"codes/**/*.ts",
"codes/**/*.tsx",
"shims/**/*.ts"
]
}
排除node_modules
的原因是编译器独立于库,因为任何包都应该编译为 JS。如果一个包没有编译版本,我会认为它不安全。