Angular 2 RC.5 & VS 2015: Cannot find name 'module', 'Set', 'Map', 'MapConstructor', 'SetConstructor'

时间:2016-08-31 17:42:38

标签: angular typescript typescript-typings

The issue that I'm having is in the title. Everything that I've read says that it's a typings issue, but I haven't been able to track it down yet. It's a pretty large project, so I'll only give a few example of my settings:

tsconfig.json

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

typings.json

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160807145350"
  }
}

package.json

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/compiler-cli": "0.5.0",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.17",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings":"^1.3.3"
  }
}

Things I have tried:

  1. Referencing typings files directly in my app's entrypoint
  2. Changing compilerOptions -> target to es6/es2015
  3. Uninstalling and reinstalling the typings references in the root
  4. Updating the typings.json to the most up-to-date versions
  5. installing es6-shim and its typings

Any other suggestions would be much appreciated.

enter image description here

2 个答案:

答案 0 :(得分:1)

您的package.json上方有"typescript":"^1.8.10",但如果您在过去一两天内更新为2.0.2,那么使用Typescript可能会this bug。如果是这样,降级到早期版本应该修复它。

您的错误消息与angular-cli上this issue中报告的错误消息非常相似  项目

答案 1 :(得分:0)

几乎忘记了这个问题......

我通过从项目中删除了nuget包Typescript.Compiler和Typescript.MsBuild来解决这个问题。