Type Script:중복 식별자 'IteratorResult'
컴파일을 하려고 합니다.tsc
--글로벌에 인스톨 하면, 다음의 에러가 표시됩니다.
~/AppData/Roaming/nvm/v11.15.0/node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.
41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
~~~~~~~~~~~~~~
node_modules/@types/node/index.d.ts:170:11
170 interface IteratorResult<T> { }
~~~~~~~~~~~~~~
'IteratorResult' was also declared here.
node_modules/@types/node/index.d.ts:170:11 - error TS2300: Duplicate identifier 'IteratorResult'.
170 interface IteratorResult<T> { }
~~~~~~~~~~~~~~
~/AppData/Roaming/nvm/v11.15.0/node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
~~~~~~~~~~~~~~
'IteratorResult' was also declared here.
Found 2 errors.
있습니다@types/node
버전 10.1.0 이 인스톨 되어 있습니다.(@latest
독자적인 문제가 있다...)
tsconfig.json
{
"compilerOptions": {
"target": "es2018",
"moduleResolution": "node",
"module": "commonjs",
"jsx": "react",
"lib": [
"dom",
"es2018",
"dom.iterable",
"scripthost"
],
"typeRoots": [
"./node_modules/@types",
"./types"
],
"types": [],
"alwaysStrict": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"sourceMap": true,
"outDir": "dist"
},
"files": [
"app/index.tsx"
],
"include": [
"app/**/*.ts",
"app/**/*.tsx",
"test/**/*.ts",
"test/**/*.tsx",
"node_modules/@types/**/*.d.ts",
"./types/**/*.d.ts"
],
"exclude": [
"dist"
]
}
언인스톨 했을 경우typescript
글로벌하게 실행npx tsc
동작하지만 설치 및 실행에는 문제가 없습니다.typescript
글로벌하게결국, 이것이 글로벌하게 제품을 설치하는 목적의 전부입니다.
그동안 저는 tsc(Windows에서 git bash를 사용하고 있습니다)에일리어스만 붙이는 회피책이 있습니다.
alias tsc="path/to/project/node_modules/.bin/tsc.cmd"
GitHub - https://github.com/microsoft/TypeScript/issues/32333에서 관련된 문제를 발견했습니다.@rbuckton은 업그레이드를 제안했습니다.@types/node
.그것은 나에게 효과가 있었다.
각도가 8인 앱에서 is 에러가 발생했는데, 여기에서 제시된 모든 제안을 수락한 답변을 포함하여 시도해도 문제를 해결할 수 없었습니다.저는 오류 없이 컴파일된 이전의 각진6 앱을 보고 다음을 포함하면 라이브러리 체크를 생략할 수 있다는 것을 깨달았습니다.
"skipLibCheck" : true
tsconfig.json 파일로 이동합니다.앱이 문제없이 잘 작동하고 있다는 사실에 저는 이 방법을 택하기로 했습니다.다음은 tsconfig.json 파일의 전체 구성입니다.
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"skipLibCheck": true
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
이 설정 후 에러는 발생하지 않았습니다.주의: 문제가 해결된 것은 아니지만 적어도 에러의 원인이 되고 있는 버그를 건너뛸 수 있었습니다.앱이 예상대로 동작하고 있기 때문에, 이 에러는 현시점에서는 무관하다고 생각했을 뿐입니다.
인크루드 섹션이 원인인 것 같습니다.
"include": [
"app/**/*.ts",
"app/**/*.tsx",
"test/**/*.ts",
"test/**/*.tsx",
"node_modules/@types/**/*.d.ts",
"./types/**/*.d.ts"
]
일반적으로 *.d.ts 파일을 명시적으로 포함할 필요가 없습니다.또한 다른 라이브러리(또는 노드 유형)에서 파일을 선언하지 않을 수도 있습니다.
tsconfig
님의 "disclosed" 섹션은 아래의 모든 내용을 제외합니다."node_modules"
디폴트로는 (특히)추가할 때"node_modules/@types/**/*.d.ts"
제외된 유형을 재정의하고 tsc에서 포함하려고 하지만 이러한 유형은 이미 선언되었습니다.
tsconfig.json의 Typescript docs를 체크하여 "typeRoots", "files" 및 "include"/"exclude" 구성 옵션에 대해 자세히 설명합니다.
나는 알고보니...node_modules
상위 디렉토리 프로젝트의 폴더는 다음과 같습니다.
node_modules
my-project
- node_modules
그 이후로는node_modules
보다 오래된 버전을 가지고 있었다@types/node
인스톨 되어 문제가 발생.에는 그런데 그 이 업데이트 되지 @types/node
, 그 「이러한」을 해 주세요.node_modules
애초에 안 썼으니까
node_modules
타입의 에서, 「다음에」, 「다음에」를 할 수 .러,,, 음음음음음,typeRoots
구체적으로는 다음과 같습니다.
{
"compilerOptions": {
"module": "esnext",
"target": "es6",
"declaration": true,
"outDir": "./dist",
"typeRoots": ["./node_modules/@types/"]
},
"include": [
"src/**/*"
]
}
하면 '''가node_modules
유형이 검색되지 않습니다.그 이외의 경우는, https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types 를 참조해 주세요.
기본적으로는 표시되는 모든 "@types" 패키지가 컴파일에 포함됩니다.엔클로징 폴더의 node_modules/@types 내의 패키지는 표시되는 것으로 간주됩니다.구체적으로는 ./node_modules/@types/, ../../node_modules/@types/ 등의 패키지를 의미합니다.
@ 것처럼 @Mohammad bin Yusrat를 합니다.npm i @types/node@latest
)npm i @types/node
를 919로 한 지 안 된 는 동작하지 않습니다.이치노
5를 한 후 ionic 5 했습니다.ionic serve
-> '로컬 호스트: 8100/localicon.ico'입니다....」(아래를 참조).
다른 'IteratorResult' 오류는 "Spread Types" 오류로 인해 발생했습니다.유형 스크립트: 개체 유형에서만 스프레드 유형을 만들 수 있습니다.기본적으로 코드 어딘가에서 이와 같은 확산 연산자를 사용했을 것입니다.return { id: doc.payload.id, ...doc.payload.data() };
이 '이러다'로 돼요.return { id: doc.payload.id, ...doc.payload.data() as {} };
, 「」를 추가합니다.as {}
skipLibCheck: true
compilerOptions
tsconfig.json으로 합니다.
이것으로 문제가 해결되었다.여기를 체크해 주세요
실행으로 유형/노드를 제거했습니다.
sudo npm remove @types/node
다음 명령어를 실행하여 다시 설치했습니다.
sudo npm i @types/node
만 하면 .@types/node
project Angular의 Devendencies:
npm i --save-dev @types/node
*****는 아무것도 node_modules
이게 도움이 될 수도 있어
Angular를 v8.2.11 또는 v9.1.13에서 업그레이드하는 것과 유사한 문제가 있었습니다.절차를 따라 문제를 해결할 수 있었습니다.
- 를제 remove remove remove를 remove remove 를 remove 。
node_modules
및 " " " "package-lock.json
- 합니다.
npm install
이렇게 해결했습니다.
npm uninstall --save-dev webpack
npm install --save-dev @angular-devkit/build-angular@latest
오류를 검색한 후 이 스레드를 찾았습니다.문제는 불필요한 수입품이 있어서 이 문제가 발생했다는 것입니다.
import { error } from 'protractor';
이 문제는 node_modules/@types/node/index.d.ts 파일의 인터페이스 "IteratorResult" 선언 중 하나를 코멘트하여 수동으로 해결했습니다.이게 도움이 되길 바라.
언급URL : https://stackoverflow.com/questions/57331779/typescript-duplicate-identifier-iteratorresult
'programing' 카테고리의 다른 글
JSON 구문은 오브젝트에 중복된 키를 허용합니까? (0) | 2023.03.13 |
---|---|
서비스 데이터 변경 시 범위 값 업데이트 (0) | 2023.03.13 |
JavaScript의 Json 데이터에서 백슬래시 제거 (0) | 2023.03.13 |
AngularJS $http, CORS 및 http 인증 (0) | 2023.03.08 |
angular.js에서 HTML5 푸시 스테이트 사용 (0) | 2023.03.08 |