繁体   English   中英

Angular 4.4.7 Typescript 2.7.2 获取 TS1005: ';'

[英]Angular 4.4.7 Typescript 2.7.2 Getting TS1005: ';'

我无法构建我的项目,得到很多关于lib.es6.d.ts的错误

node_modules/typescript/lib/lib.es6.d.ts(20605,14): 错误 TS1005: ';' 预期的。

在此处输入图像描述

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 打字稿

+-- @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>

我看起来你可能有一些不匹配的角度版本。 您的标题显示 Angular 版本 4.4.7。 你的树说 angular-cli 6.2.9,你的打字稿版本是 2.7.2。 angular 和 angular-cli 的 Typescript 要求会有所不同。 我会首先通过降级 cli 或升级 angular 来对齐这些版本。 然后擦除你的 node_modules 文件夹并重新安装 npm。 用于 angular/angular-cli 升级的有用工具这里

条件类型中的类型推断和打字稿中的条件类型仅在 2.8 版本中添加。 之前的版本不支持这个。

我已经在这个操场上复制了你的问题。 我已选择 2.7.2 作为打字稿版本,并且可以看到您所看到的确切错误。

如果我在这里使用 typescript 2.8.1,这个错误就会消失。 所以如果你想在你的代码中支持条件类型,你必须至少升级到 2.8.1。

或者您可以从代码中完全删除条件类型声明。 作为 2.8 的一部分引入的功能的完整列表可在此处找到

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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