I have a base tsconfig.json
where I want to have all consistent properties for all projects that reference it.
I was hoping I could persistently put the outDir
, rootDir
, include
and excludes
here:
{
"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"
]
}
Unfortunately
{
"extends": "../frontend-common/typescript/tsconfig.base.json",
}
But when I try and compile a project, I get this error:
error TS6059: File 'blah.ts' is not under 'rootDir' '/path/to/tsconfig.base.json/dir'. 'rootDir' is expected to contain all source files.
File paths in tsconfig.base.json
are probably unsurprisingly relative to that file's location.
Is there any way of making them relative to the tsconfig.json
that references the base tsconfig.base.json
?
It is annoying to have this in each tsconfig.json
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"./dist",
"src/**/*.test.ts",
"src/**/*.test.tsx"
]
This has been added in TypeScript 5.5
You can now use ${configDir}
as placeholder in your tsconfig.base.json
:
{
"compilerOptions": {
"outDir": "${configDir}/dist"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With