How to handle a project with multiple tsconfig.json files?
Solution 1
Is there a way to tell TypeScript where to look for typings
Quickest solution
Move typings
into pref.
Long term solution
Use filesGlob
once it is supported in tsc
: https://github.com/Microsoft/TypeScript/issues/1927
Solution 2
you can do this by extending your base tsconfig.json file:
just do not exclude directories in the base tsconfig.json and typescript should be able to resolve your typings for you (know this is true using node_modules/@types, or the typings module)
For example:
configs/base.json:
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true
}
}
tsconfig.json:
{
"extends": "./configs/base",
"files": [
"main.ts",
"supplemental.ts"
]
}
tsconfig.nostrictnull.json:
{
"extends": "./tsconfig",
"compilerOptions": {
"strictNullChecks": false
}
}
BrunoLM
I'm a Developer for Fun! Things I like Code Play games Anime / Manga Contact information [email protected] LinkedIn Facebook Site - https://brunolm.github.io/ Blog - http://blog.codingwise.com/
Updated on July 07, 2022Comments
-
BrunoLM almost 2 years
I'm working on a project structured like this:
\ |- built |- src |- perf |- tsconfig.json |- typings |- tsconfig.json
My
tsconfig.json
on the root"target": "es6", "outDir": "built", "rootDir": "./src",
I need a different configuration on the
perf
folder, like a different target."target": "es5",
However, my
typings
folder is on the root of my project, not insideperf
folder. So doing atsc ./perf
results in a lot of errors.Is there a way to tell TypeScript where to look for
typings
? I'm usingnpm install -g typescript@next // [email protected]
Or a way to have different configurations depending on the folder?
-
miken32 over 7 yearsLink-only answers are not useful when the content changes or is removed. Include the relevant parts of the page in your answer, tailored to answer the question.
-
vintprox almost 5 yearsThat is unrecognizable. That means I can't have multiple tsconfigs.