-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
TypeScript Version: 3.8.0-dev.20200207
Search Terms: jsconfig extend override defaults
Code
// b/jsconfig.json
{
"extends": "../a/jsconfig.json"
}// a/test.js
console.log("hello");Reproduce
mkdir -p a b
echo '{"files":["test.js"],"compilerOptions":{"maxNodeModuleJsDepth":0}}' > a/jsconfig.json
echo '{"extends":"../a/jsconfig.json"}' > b/jsconfig.json
echo 'console.log("hello");' > a/test.jsnpx tsc -p a/jsconfig.json --showConfig
npx tsc -p b/jsconfig.json --showConfigExpected behavior:
Both implied configs A and B have compilerOptions.maxNodeModuleJsDepth: 0.
Actual behavior:
Implied config A has compilerOptions.maxNodeModuleJsDepth: 0.
Implied config B has compilerOptions.maxNodeModuleJsDepth: 2.
Output:
{
"compilerOptions": {
"allowJs": true,
"maxNodeModuleJsDepth": 0,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"noEmit": true
},
"files": [
"./test.js"
]
}
{
"compilerOptions": {
"allowJs": true,
"maxNodeModuleJsDepth": 2,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"noEmit": true
},
"files": [
"../a/test.js"
]
}Implied config B has maxNodeModuleJsDepth: 2 despite it extending config A which explicitly sets maxNodeModuleJsDepth: 0.
Possible cause
This may be caused by the default values for config files named jsconfig.json overriding the values from the extended config. maxNodeModuleJsDepth: 2 is one of the default values. See: /src/compiler/commandLineParser.ts#L2459
Solution
Default values for jsconfig.json config files should not override values explicitly defined by the extended configs.
Workaround
Explicitly set the following values in config files named jsconfig.json that extend other configs with non-default values:
allowJsmaxNodeModuleJsDepthallowSyntheticDefaultImportsskipLibChecknoEmit