我有一个基础tsconfig.json
,我希望在其中为所有引用它的项目提供所有一致的属性。
我希望我能坚持把outDir
、rootDir
、include
和excludes
放在这里:
{
"compilerOptions": {
"declaration": true,
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"noUnusedLocals": true,
"outDir": "./dist",
"removeComments": false,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es5"
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"./dist",
"src/**/*.test.ts",
"src/**/*.test.tsx"
]
}
不幸的是
{
"extends": "../frontend-common/typescript/tsconfig.base.json",
}
但当我尝试编译一个项目时,我会得到这样的错误:
错误TS6059:文件"blah.ts"不在"rootDir"/path/tosconfig.base.json/dir"下。"rootDir"应包含所有源文件。
tsconfig.base.json
中的文件路径相对于该文件的位置可能并不令人意外。
有没有任何方法可以使它们相对于引用基础tsconfig.base.json
的tsconfig.json
?
在每个tsconfig.json
中都有这种情况很烦人
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"./dist",
"src/**/*.test.ts",
"src/**/*.test.tsx"
]
我也在寻找类似的东西,但到目前为止还没有同样的方法。
参考问题-https://github.com/microsoft/TypeScript/issues/29172