gpt4 book ai didi

angular - VS2019 错误 TS2300 : Duplicate identifier IteratorResult

转载 作者:行者123 更新时间:2023-12-03 15:09:22 27 4
gpt4 key购买 nike

我有一个 ASP.NET Core 项目,里面有 Angular App。
将项目更新到 .NET Core 3.0 版本后,我遇到了一个问题。
在 ASP.NET Core 项目构建期间,我在输出中看到 2 个错误:

1>------ Build started: Project: Portal, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.6\lib.es2015.iterable.d.ts(41,6): error TS2300: Build:Duplicate identifier 'IteratorResult'.
1>D:\Solution\MyProject\ClientApp\node_modules\@types\node\index.d.ts(73,11): error TS2300: Build:Duplicate identifier 'IteratorResult'.
1>MyProject -> D:\Solution\MyProject\bin\Debug\netcoreapp3.0\Portal.dll
1>Done building project "Portal.csproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

包.json:
{
"name": "client-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-dev": "ng build --configuration=development"
},
"private": true,
"dependencies": {
"@angular/animations": "^8.2.2",
"@angular/cdk": "~8.1.3",
"@angular/common": "~8.2.0-next.1",
"@angular/compiler": "~8.2.0-next.1",
"@angular/core": "~8.2.0-next.1",
"@angular/forms": "~8.2.0-next.1",
"@angular/platform-browser": "~8.2.0-next.1",
"@angular/platform-browser-dynamic": "~8.2.0-next.1",
"@angular/router": "~8.2.0-next.1",
"core-js": "^2.5.4",
"primeflex": "^1.0.0-rc.1",
"primeicons": "^1.0.0",
"primeng": "^8.0.1",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.801.1",
"@angular/cli": "~8.1.1",
"@angular/compiler-cli": "~8.2.0-next.1",
"@angular/language-service": "~8.2.0-next.1",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "3.4.5"
}
}

tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}

我试过的:
  • 通过npm更新@type/node;
  • 从 package.json 中删除 @type/node;
  • 将 typescript (package.json 的底部)版本更改为 3.6.4。
  • 最佳答案

    我也遇到了与 Vs2019 和 angular 版本 8 完全相同的问题。我已经按照上面的建议尝试为 VS2019 下载并安装 TypesScript 编译器版本 3.7。但问题仍然存在。

    解决上述问题的唯一方法是按照J King的建议升级8.10.52版本以上的节点类型。在 tsconfig.json 文件中,我将编译器目标版本设置为 ES6。然后发出以下命令:

    npm install @types/node@8.10.52

    然后做:

    构建

    确保它构建干净。在 Vs2019 中进行干净的构建。

    这似乎解决了问题。

    关于angular - VS2019 错误 TS2300 : Duplicate identifier IteratorResult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58485673/

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