microsoft / microsoft/TypeScript
Default values for jsconfig.json override extended values
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in src/compiler/commandLineParser.ts, nella gestione dei valori predefiniti di jsconfig a cui fa riferimento l’issue. Riproduci il problema con le due configurazioni e confronta npx tsc -p ... --showConfig per ciascuna. Il lavoro è completato quando i valori definiti esplicitamente da una configurazione estesa vengono preservati invece di essere sostituiti dai valori predefiniti di jsconfig.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 30/100