gpt4 book ai didi

angular - 更新 tsconfig.json 和 package.json 后的错误

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

对于某些情况,我刚刚开始浏览此处的提前编译指南,但我认为我的错误与它没有直接关系:https://angular.io/guide/aot-compiler

我正在使用 Visual Studio 2015 并将我的 Angular 2 项目更新为新发布的 2.4,一切都构建得很好。然而,我随后更改了我的 tsconfig.json 文件以将 "lib": [ "es2015", "dom"] 添加到我的 compilerOptions。该文件现在看起来像这样:

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"removeComments": false,
"noImplicitAny": true,
"outDir": "dist",
"suppressImplicitAnyIndexErrors": true
},
"compileOnSave": true
}

此更改后,我重新构建并得到以下构建错误:

Build: duplicate identifier 'PropertyKey'.

我做了一些研究并决定从我的 package.json 文件中删除 "@types/core-js": "^0.9.34",这似乎解决了那个错误,但我现在有以下新错误的几个实例:

Build: Cannot find name 'Set'

Build: Cannot find name 'Promise'

Build: Cannot find name 'Map'

这是我的完整 package.json 文件:

{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"pree2e": "npm run webdriver:update",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings",
"webdriver:update": "webdriver-manager update"
},
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "^2.4.1",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/platform-server": "^2.4.1",
"@angular/router": "~3.4.0",
"@angular/upgrade": "~2.4.0",
"angular-in-memory-web-api": "~0.1.16",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.39",
"zone.js": "^0.7.4"
},
"devDependencies": {
"@types/node": "^6.0.45",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3"
},
"repository": {}
}

为了保持新版本的更新,我几乎一直在此处复制示例 package.json 文件的依赖项部分:https://angular.io/guide/quickstart

该链接适用于 JavaScript 版本,因为这是我能找到的唯一版本,但我实际上使用的是 TypeScript 2.1.4。因此,我可能有此文件的某些部分已过时。我只是不确定如何具体确定哪些部分。

最佳答案

I am not familiar with Visual Studio setup (intellij user). But maybe try using. "lib": [ "es6", "dom" ], Or possibly remove "lib": [ "es20125", "dom" ], completely and try using core-js @types. Look at my answer here on how to use core-js.

相关答案:

Angular 2 can't find Promise,Map,Set and Iterator

找不到名称“Promise” 这个错误让我相信您缺少 ES6 的类型定义。

Promise、Map 和 Set 是 es6 规范。

您应该使用 ES6 pollyfill 库。

关于angular - 更新 tsconfig.json 和 package.json 后的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41470359/

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