gpt4 book ai didi

angular - 如何修复 Angular 错误 : TS1039 in compiling?

转载 作者:行者123 更新时间:2023-12-05 07:26:21 26 4
gpt4 key购买 nike

当我编译我的项目时出现下一个错误:


ERROR in node_modules/@angular/common/http/src/response.d.ts(253,21): error TS1039: Initializers are not allowed in ambient contexts.
node_modules/@angular/common/http/src/response.d.ts(259,19): error TS1039: Initializers are not allowed in ambient contexts.
node_modules/@angular/core/src/application_init.d.ts(26,21): error TS1039: Initializers are not allowed in ambient contexts.
node_modules/@angular/core/src/ivy_switch/compiler/ivy_switch_on.d.ts(12,35): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
node_modules/@angular/core/src/ivy_switch/compiler/legacy.d.ts(19,35): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
node_modules/@angular/core/src/linker/query_list.d.ts(36,22): error TS1039: Initializers are not allowed in ambient contexts.

我该如何解决这个问题?我尝试删除 node_modules 并重新安装它。但这对我没有帮助。

Package.json:

"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.2.2",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "^7.0.4",
"@angular/material": "^7.2.2",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"@fortawesome/fontawesome-free": "^5.5.0",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"highlight.js": "^9.13.1",
"material-icons": "^0.2.3",
"ng2-file-upload": "latest",
"ngx-highlightjs": "^3.0.0",
"roboto-fontface": "^0.10.0",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},

有什么可以帮助别人的吗?

最佳答案

这可能是因为您的 TypeScript 版本需要更新。

在这里查看这个问题:#42301181 Initializers are not allowed in ambient contexts

尝试使用最新版本的 TypeScript 编译您的项目。

关于angular - 如何修复 Angular 错误 : TS1039 in compiling?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54370109/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com