TypeScript 2.1+ tsconfig扩展

Den*_*ann 9 inheritance typescript tsconfig

当前,我正在尝试tsconfig.json中的新扩展功能,该功能允许开发人员拥有基本的tsconfig.json,其他模块可以扩展/修改。

它正在工作,尽管没有达到预期。不知何故,唯一可行的方法是在父配置和子配置中都指定Compileroptions.lib。

parent.tsconfig.json

 {
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "lib": [ // Lib compiler options defined!!! 
      "dom",
      "es6"
    ]
  },
  "exclude": [
    "node_modules"
  ],
  "awesomeTypescriptLoaderOptions": {
    "resolveGlobs": true,
    "forkChecker": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}
Run Code Online (Sandbox Code Playgroud)

child.tsconfig.json(预期)

{
  "extends": "../parent.tsconfig.json",
}  
Run Code Online (Sandbox Code Playgroud)

child.tsconfig.json(必须工作)

{
  "extends": "../parent.tsconfig.json",
  "compilerOptions": {
    "lib": [ //Have to specify lib again ==> Double-u-t-f
      "dom",
      "es6"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

对此问题的一些建议将不胜感激。

干杯

Kar*_*ius 0

你做的一切都是正确的。您的tsconfig.json文件应该位于当前项目的根目录中。仔细检查您的 .txt 文件中的文件路径是否parent.tsconfig.json设置正确child.tsconfig.json