Webstorm, TypeScript, Angular2, Transpiler, fejlmeddelelser om dubleret identifikator


OS: Windows Pro 10
Webstorm: ver 11.0.1
AngularJS: ver 2.0.0-alpha.46

WebStorm-indstillinger

  1. Værktøjer - Fildetektor: Babal

  2. Sprog & rammer - JavaScript:
    JavaScript sprogversion: ECMAScript 6

  3. Sprog & Rammer - TypeScript:
    Aktivér TypeScript-kompiler (markeret):
    Brug tsconfig.json (markeret)

Projektstruktur:

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

Bemærk: mappen node_modules i WebStorm-projektvinduet er også blevet sat til 'udelukke'.

Så WebStorm giver følgende fejlmeddelelser om duplikerede identifikatorer:

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'.

Hvordan løser jeg dette problem?

Mange tak på forhånd

Svar #1

Dette sker, når BEGGE filer er åbne i editoren. Hvis du lukker en af filerne, forsvinder fejlen...

Se her: Webstorm markerer fejl med duplikeret identifikator for variabler fra separate filer

Relaterede artikler