TypeScript 2.1+ tsconfig extends

不想你离开。 提交于 2021-01-26 03:44:07

问题


Currently, I am trying the new extends feature in the tsconfig.json that allows developers to have a base tsconfig.json, that other modules can extend / modify.

It is working, although not as expected. Somehow, the only way to get this working is to specifiy compileroptions.lib in both parent and child configs.

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
  }
}

child.tsconfig.json (Expected)

{
  "extends": "../parent.tsconfig.json",
}  

child.tsconfig.json (Required to work)

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

Some advice on this matter would be appreciated.

Cheers


回答1:


You are doing everything right. Your tsconfig.json file should be in the root directory of current project. Double check whether the path of parent.tsconfig.json file is correctly set in your child.tsconfig.json.



来源:https://stackoverflow.com/questions/41101971/typescript-2-1-tsconfig-extends

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!