node.jsangulartypescriptgulpgulp-typescript

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.

enter image description here

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>


Solution

  • 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