简体   繁体   中英

Angular 4.4.7 Typescript 2.7.2 Getting TS1005: ';'

I am unable to build my project getting a lot of errors about lib.es6.d.ts

node_modules/typescript/lib/lib.es6.d.ts(20605,14): error TS1005: ';' expected.

在此处输入图像描述

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "amd",
    "moduleResolution": "node",
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": false,
    "sourceMap": true,
    "noResolve": false,
    "noEmitOnError": true,
    "outDir": "dist/debug"
  },
  "filesGlob": [
    "./**/*.ts",
    "!./node_modules"
  ],
  "exclude": [
    "node_modules",
    "jspm_packages",
    "typings",
    "dist",
    "typings/*",
    "typings/main.d.ts",
    "typings/main",
    "Scripts"
  ],
  "compileOnSave": true,
  "buildOnSave": true
}

npm ls typescript

+-- @angular/cli@6.2.9
| `-- @schematics/angular@0.8.9
|   `-- typescript@2.9.2 deduped
+-- gulp-typedoc@1.2.1
| `-- typedoc@0.3.12
|   `-- typescript@1.6.2
+-- gulp-typescript@2.14.1
| `-- typescript@1.8.10
+-- tslint@3.15.1 invalid: ">=5.0.0-dev" from node_modules/gulp-tslint
| `-- typescript@2.9.2 deduped
+-- typedoc@0.2.3
| `-- typescript@1.4.1
+-- typescript@2.9.2
`-- typings@1.5.0
  `-- typings-core@1.6.1
    `-- typescript@2.9.2 deduped

PS C:\WebProjects\COTT\COTT\OrderTemplateTool.Web>

I looks like you might have some mismatching versions of angular. Your title says Angular version 4.4.7. Your tree says angular-cli 6.2.9 and you typescript version on 2.7.2. Typescript requirements are going to be different for angular and angular-cli. I would align those versions first by either downgrading cli or upgrading angular. Then wipe your node_modules folder and do a fresh npm install. Helpful tool for angular/angular-cli upgrades HERE

Type inference in conditional types & Conditional Types in typescript only gets added in 2.8 release. Prior release don't support this.

I have reproduced your issue with this playground . I have selected 2.7.2 as typescript version & can see exact error which you are seeing.

If I use typescript 2.8.1 as here , this error disappears. So if you want support of conditional types in your code, you have to upgrade to 2.8.1 at least.

Or you can completely remove conditional type declaration from your code. Complete list of features which are introduced as a part of 2.8 are found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM