microsoft / microsoft/TypeScript
Default values for jsconfig.json override extended values
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
TypeScript Version: 3.8.0-dev.20200207
Search Terms: jsconfig extend override defaults
Code
// a/jsconfig.json
{
"files": ["test.js"],
"compilerOptions": {
"maxNodeModuleJsDepth": 0
}
}
// 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.js
npx tsc -p a/jsconfig.json --showConfig
npx tsc -p b/jsconfig.json --showConfig
Expected 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in src/compiler/commandLineParser.ts bei der im issue referenzierten Behandlung von Standardwerten für jsconfig. Reproduziere das Problem mit den beiden Konfigurationen und vergleiche npx tsc -p ... --showConfig für jede davon. Als erledigt gilt die Aufgabe, wenn explizit definierte Werte aus einer erweiterten Konfiguration erhalten bleiben, statt durch jsconfig-Standardwerte ersetzt zu werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 30/100