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

时间:2015-12-10 09:56:06

标签: typescript duplicates ecmascript-6 webstorm angular

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

WebStorm设置

  1. 工具 - 文件观察器: Babal

  2. 语言&框架 - JavaScript:
    JavaScript语言版本: ECMAScript 6

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

  4. 项目结构:

    - bin
    - node_modules/angular2
    - src/tsconfig.json
    - package.json
    

    的package.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"
      }
    }
    

    tsconfig.json

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

    注意:webstorm项目窗口中的node_modules文件夹也已设置为' exclude'。

    因此,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'.
    

    如何解决此问题?

    非常感谢提前

1 个答案:

答案 0 :(得分:-1)

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

在这里查看:Webstorm marks duplicate identifier error for variables from separate files