更新tsconfig.json和package.json之后的错误

时间:2017-01-04 17:59:22

标签: angular typescript angular2-aot

在某些情况下,我刚刚开始浏览此处找到的Ahead-of-time编译菜谱,但我不相信我的错误与它直接相关:https://angular.io/guide/aot-compiler

我正在使用Visual Studio 2015并将我的Angular 2项目更新到新发布的2.4并且所有内容都很好。然而,我改变了我的tsconfig.json文件,将"lib": [ "es2015", "dom" ]添加到了我的compilerOptions。该文件现在看起来像这样:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "removeComments": false,
    "noImplicitAny": true,
    "outDir": "dist",
    "suppressImplicitAnyIndexErrors": true
  },
  "compileOnSave": true
}

在此更改之后,我重新构建并获得以下构建错误:

  

构建:重复标识符' PropertyKey'。

我做了一些研究并决定从我的package.json文件中删除"@types/core-js": "^0.9.34",这似乎已经解决了这个错误,但我现在有几个以下新错误的实例:

  

构建:找不到名称'设置'

     

构建:找不到名字'承诺'

     

构建:找不到名称'地图'

这是我的完整package.json文件:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "docker-build": "docker build -t ng2-quickstart .",
    "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
    "pree2e": "npm run webdriver:update",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "postinstall": "typings install",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "webdriver:update": "webdriver-manager update"
  },
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/compiler-cli": "^2.4.1",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/platform-server": "^2.4.1",
    "@angular/router": "~3.4.0",
    "@angular/upgrade": "~2.4.0",
    "angular-in-memory-web-api": "~0.1.16",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.1",
    "systemjs": "0.19.39",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "@types/node": "^6.0.45",
    "concurrently": "^3.0.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.3"
  },
  "repository": {}
}

为了不断更新新版本,我在这里复制了示例package.json文件的依赖项部分:https://angular.io/guide/quickstart

该链接适用于JavaScript版本,因为这是我能找到的唯一链接,但我实际上使用的是TypeScript 2.1.4。因此,我可能有这个文件的某些部分已经过时了。我不知道如何具体确定哪些部分。

1 个答案:

答案 0 :(得分:0)

  

我不熟悉Visual Studio设置(intellij用户)。但也许吧   尝试使用。 “lib”:[“es6”,“dom”],或者可能删除“lib”:[   “es20125”,“dom”],完全尝试使用core-js @types。看着   我在这里回答如何使用core-js。

相关答案:

Angular 2 can't find Promise,Map,Set and Iterator

Cannot find name 'Promise'此错误让我误以为您缺少ES6的类型定义。

Promise,Map和Set是es6规范。

您应该使用ES6 pollyfill库。