microsoft / microsoft/TypeScript
Default values for jsconfig.json override extended values
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/compiler/commandLineParser.ts の、issue で参照されている jsconfig のデフォルト値の処理から始めます。2 つの設定で問題を再現し、それぞれについて npx tsc -p ... --showConfig を比較します。拡張された設定で明示的に定義された値が、jsconfig のデフォルト値に置き換えられず保持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 30/100