Angular 4.4.7打字稿2.7.2获取TS1005:&#x27 ;;'
我无法构建我的项目遇到很多关于 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 typescript
+-- @angular/[email protected]
| `-- @schematics/[email protected]
| `-- [email protected] deduped
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected] invalid: ">=5.0.0-dev" from node_modules/gulp-tslint
| `-- [email protected] deduped
+-- [email protected]
| `-- [email protected]
+-- [email protected]
`-- [email protected]
`-- [email protected]
`-- [email protected] deduped
PS C:\ webprojects \ cott \ cott \ cott \ cott \ ordertemplatetool.web>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有条件类型&
我已经通过此 Playground 。我选择了2.7.2作为打字稿版本&可以看到您看到的确切错误。
If I use typescript 2.8.1 as here, this错误消失了。因此,如果您想支持代码中的条件类型,则至少必须升级到2.8.1。
或者,您可以从代码中完全删除条件类型声明。
找到作为2.8一部分的功能的完整列表,找到了在这里
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
我看起来您可能有一些不匹配的角度。您的标题说Angular版本4.4.7。您的树说Angular-CLI 6.2.9,您的打字稿版本在2.7.2上。对于角度和角度CLI,打字稿要求将有所不同。我会首先通过降低CLI或升级角度来对齐这些版本。然后擦除node_modules文件夹,然后安装新的NPM。 Angular/Angular-CLI升级的有用工具
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