【问题标题】:Excluding node_modules directory from tsconfig still being compiled从 tsconfig 中排除 node_modules 目录仍在编译
【发布时间】:2017-01-02 02:36:39
【问题描述】:

在针对 ES6 时,我遇到了一些 TS2300 重复标识符错误。

node_modules/typescript/lib/lib.es6.d.ts(17,14): error TS2300: Duplicate identifier 'PropertyKey'.              
node_modules/typescript/lib/lib.es6.d.ts(26,5): error TS2300: Duplicate identifier '[Symbol.toStringTag]'.     
node_modules/typescript/lib/lib.es6.d.ts(33,5): error TS2300: Duplicate identifier 'prototype'.               
node_modules/typescript/lib/lib.es6.d.ts(61,5): error TS2300: Duplicate identifier 'hasInstance'.

这是我的tsconfig.json

{
    "compilerOptions": {
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "noImplicitAny": false,
        "sourceMap": true,
        "target": "es6",
        "suppressImplicitAnyIndexErrors": true
    },
    "exclude": [
        "node_modules"
    ]
}

我不确定为什么编译器在排除 node_modules 目录中的任何内容时仍然会抛出错误。我遵循了this 的建议,仍然出现同样的错误。

FWIW 我正在使用此命令进行编译。

./node_modules/.bin/tsc -p ./src

这似乎在使用 v2 beta 时有效。但是很高兴知道为什么使用 v1.8 会失败。我在 GitHub 上找不到任何报告的错误。

我错过了什么?

【问题讨论】:

    标签: typescript typescript1.8


    【解决方案1】:

    我错过了什么?

    类似的结构在 2.0 中不再出错。在 1.8 中使用过。这就是修复错误的原因。

    【讨论】:

    • 这是否意味着无法使用当前稳定的 TypeScript 编译器来定位 ES6?
    • @onetwothree FWIW,TypeScript 2.0 现已发布。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 2020-03-20
    相关资源
    最近更新 更多