更新到Angular 9和Typescript 3.8.3后生成错误

时间:2020-05-09 12:05:25

标签: angular typescript

将我的WebAPI项目更新为Angular 9和Typescript 3.8.3之后,在构建应用程序时出现错误: enter image description here

然后我尝试执行一些命令,删除node_modules并执行npm install,然后尝试更新依赖项,因此最终获得了Angular预览版本(10)。

我仍然有那些错误,我不确定下一步该怎么做。

这是tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "module": "es2020",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

什么可能导致此问题?

编辑 我将Angular降级到版本9,然后删除了node_modules并执行了npm i命令,但仍然有错误。 现在是我的package.json

{
  "name": "score-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.6",
    "@angular/cdk": "^9.2.3",
    "@angular/common": "^9.1.6",
    "@angular/compiler": "^9.1.6",
    "@angular/core": "^9.1.6",
    "@angular/forms": "^9.1.6",
    "@angular/localize": "^9.1.6",
    "@angular/material": "^9.2.3",
    "@angular/material-moment-adapter": "^9.2.3",
    "@angular/platform-browser": "^9.1.6",
    "@angular/platform-browser-dynamic": "^9.1.6",
    "@angular/router": "^9.1.6",
    "@ng-bootstrap/ng-bootstrap": "^5.3.1",
    "angular-bootstrap-datetimepicker": "^4.0.2",
    "angular-md2": "^6.3.0",
    "bootstrap": "^4.4.1",
    "compressible": "^2.0.18",
    "jquery": "^3.5.1",
    "moment": "^2.25.3",
    "ngx-material-timepicker": "^4.0.2",
    "ngx-tempusdominus-bootstrap": "^1.0.1",
    "ngx-toastr": "^10.2.0",
    "popper.js": "^1.16.1",
    "rxjs": "^6.5.5",
    "tempusdominus-bootstrap-4": "^5.1.2",
    "tempusdominus-core": "^5.0.3",
    "tslib": "^1.11.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.5",
    "@angular/cli": "^9.1.5",
    "@angular/compiler-cli": "^9.1.6",
    "@angular/language-service": "^9.1.6",
    "@types/jasmine": "^3.3.16",
    "@types/jasminewd2": "^2.0.8",
    "@types/jquery": "^3.3.38",
    "@types/node": "^12.12.38",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.3",
    "protractor": "~5.4.4",
    "ts-node": "~7.0.0",
    "tslint": "~6.1.0",
    "typescript": "^3.8.3"
  }
}

似乎我仍然遇到相同的错误: enter image description here

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题。问题是视觉工作室使用的打字稿版本错误。

只需为Visual Studio安装this version即可对其进行修复。