Search code examples
angularasp.net-core-mvctypescript1.6typescript1.7

ASP.NET 5 MVC6 Angular 2 (Beta 0) - duplicate promise


Hello,

I am receiving a build error on my MVC6 Angular (Beta 0) project. I am attempting to setup the project found at: https://angular.io/guide/quickstart

"Duplicate identifier 'Promise'"

It would appear to be defined in both:

  • es6-shim.d.ts
  • es6-promise.d.ts

My tsconfig.json is as follows:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

If I change the above setting to es6, I get a whole lot more errors. E.g. Duplicate identifier on

done, EPSILON, flags, MAX_SAFE_INTEGER, Promise, PropertyKey, prototype, size, value.

I'm really struggling and I would prefer to avoid any 'hacks' if possible.

Note: I am using VS2015 Update 1 (compiles to TS automatically on build).

My package.json is as follows:

{
  "name": "ASP.NET",
  "version": "0.0.0",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "gulp": "3.8.11",
    "gulp-concat": "2.5.2",
    "gulp-cssmin": "0.1.7",
    "gulp-uglify": "1.2.0",
    "rimraf": "2.2.8",
    "concurrently": "^1.0.0",
    "lite-server": "^1.3.1",
    "typescript": "^1.7.3"
  }
}

I would appreciate solutions that have worked in the field but please no hacks if at all possible.


Solution

  • Suggest you delete typings, node_modules directories and tsd.json then, npm install && tsd init && tsd install angular2 --resolve --save as it appears you have some legacy. The angular typings will then look like the following (no Promises): screenshot