Webstorm、TypeScript、Angular2、Transpiler、Duplicate Identifier 错误消息

The*_*eoG 5 duplicates webstorm typescript ecmascript-6 angular

操作系统:Windows Pro 10
Webstorm:ver 11.0.1
AngularJS:ver 2.0.0-alpha.46

网络风暴设置

  1. 工具 – 文件观察者:Babal

  2. 语言和框架 – JavaScript:
    JavaScript 语言版本:ECMAScript 6

  3. 语言和框架 – TypeScript:
    启用 TypeScript 编译器(已选中)
    使用 tsconfig.json(已选中)

项目结构:

- bin
- node_modules/angular2
- src/tsconfig.json
- package.json
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "name": "TypeScriptHTMLApp2",
  "version": "1.0.0",
  "dependencies": {
    "angular2": "2.0.0-alpha.46",
    "es6-shim": "^0.33.13",
    "systemjs": "0.19.6"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.3.13"
  }
}
Run Code Online (Sandbox Code Playgroud)

配置文件

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

注意:webstorm 项目窗口中的 node_modules 文件夹也已设置为“排除”。

所以 webstorm 抛出以下重复标识符错误消息:

C:\Program Files (x86)\JetBrains\WebStorm 11.0.1\plugins\JavaScriptLanguage\typescriptCompiler\external\lib.es6.d.ts
Error:(3841, 14) TS2300: Duplicate identifier 'PropertyKey'.
Error:(4034, 5) TS2300: Duplicate identifier 'EPSILON'.
Error:(4069, 5) TS2300: Duplicate identifier 'MAX_SAFE_INTEGER'.
Error:(4076, 5) TS2300: Duplicate identifier 'MIN_SAFE_INTEGER'.
Error:(4362, 5) TS2300: Duplicate identifier 'done'.
Error:(4363, 5) TS2300: Duplicate identifier 'value'.
Error:(4592, 5) TS2300: Duplicate identifier 'flags'.
Error:(4620, 5) TS2300: Duplicate identifier 'size'.
Error:(4630, 5) TS2300: Duplicate identifier 'prototype'.
Error:(4647, 5) TS2300: Duplicate identifier 'prototype'.
Error:(4659, 5) TS2300: Duplicate identifier 'size'.
Error:(4669, 5) TS2300: Duplicate identifier 'prototype'.
Error:(4685, 5) TS2300: Duplicate identifier 'prototype'.
Error:(5072, 5) TS2300: Duplicate identifier 'prototype'.
C:\Users\Theo\Documents\WebStorm\Projects\TypeScriptHTMLApp2\TypeScriptHTMLApp2\node_modules\angular2\typings\es6-shim\es6-shim.d.ts
Error:(6, 14) TS2300: Duplicate identifier 'PropertyKey'.
Error:(9, 5) TS2300: Duplicate identifier 'done'.
Error:(10, 5) TS2300: Duplicate identifier 'value'.
Error:(248, 5) TS2300: Duplicate identifier 'EPSILON'.
Error:(283, 5) TS2300: Duplicate identifier 'MAX_SAFE_INTEGER'.
Error:(290, 5) TS2300: Duplicate identifier 'MIN_SAFE_INTEGER'.
Error:(346, 5) TS2300: Duplicate identifier 'flags'.
Error:(498, 5) TS2300: Duplicate identifier 'prototype'.
Error:(561, 5) TS2300: Duplicate identifier 'size'.
Error:(570, 5) TS2300: Duplicate identifier 'prototype'.
Error:(581, 5) TS2300: Duplicate identifier 'size'.
Error:(590, 5) TS2300: Duplicate identifier 'prototype'.
Error:(605, 5) TS2300: Duplicate identifier 'prototype'.
Error:(619, 5) TS2300: Duplicate identifier 'prototype'.
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

提前谢谢了

小智 -2

当两个文件在编辑器中打开时会发生这种情况。如果关闭其中一个文件,错误就会消失......

看这里:Webstorm 标记来自单独文件的变量的重复标识符错误