【问题标题】:TypeScript 2.1+ tsconfig extendsTypeScript 2.1+ tsconfig 扩展
【发布时间】:2016-12-12 13:27:15
【问题描述】:

目前,我正在尝试 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
  }
}

child.tsconfig.json(预期)

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

child.tsconfig.json(工作必备)

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

我们将不胜感激有关此问题的一些建议。

干杯

【问题讨论】:

  • sourcemap 等,似乎也对我不起作用,使用 tsc 时没有明显错误,但 VS 2015 也强烈抱怨缺少模块和目标。
  • 这很奇怪,它对我们有用
  • 我查看了代码 (github.com/Microsoft/TypeScript/blob/master/src/compiler/…),因为我们遇到了同样的问题。看起来它应该可以工作,因为它会从继承的选项中复制任何不在 tsconfig 编译器选项(由 hasOwnProperty 确定)中的内容。

标签: inheritance typescript tsconfig


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-06-12
    • 2020-04-02
    • 1970-01-01
    • 2021-03-29
    • 1970-01-01
    • 2016-06-08
    • 2018-07-09
    • 2012-09-26
    • 2019-12-06
    相关资源
    最近更新 更多