'relative paths for outDir and rootDir in a base tsconfig.json
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"
]
Solution 1:[1]
I was also looking for something similar, but as of now there is no way to do the same.
Reference issue - https://github.com/microsoft/TypeScript/issues/29172
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rohit Garg |