it-source

TypeScript 컴파일러용 *.d.ts 파일을 제외하는 방법은 무엇입니까?

criticalcode 2023. 6. 10. 09:26
반응형

TypeScript 컴파일러용 *.d.ts 파일을 제외하는 방법은 무엇입니까?

저는 npm 모듈 web3@1.0.0-beta를 사용합니다.index.d.ts 파일에 약간의 오류가 있는 24.

TS 컴파일러에 대해 이 파일(node_modules/web3/index.d.ts)을 무시하고 내 유형 파일을 사용하려고 합니다.

하지만 tsc는 여전히 이 잘못된 파일을 사용하고 있고 내 프로젝트를 컴파일할 수 없습니다.

다음은 내 tsconfig.json입니다.

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true
  },

  "exclude": ["node_modules/web3/index.d.ts"]
}

수동으로 제거하는 경우node_modules/web3/index.d.tstsc는 내 프로젝트를 컴파일합니다.

tsc에 대해 이 파일을 제외하는 방법은 무엇입니까?

이 문제를 재현하기 위해 최소한의 코드로 레포를 만들었습니다. https://github.com/serge-nikitin/q1

컴파일하는 동안 lib 선언 파일 검사를 무시하려면 tsconfig.json에 이 옵션을 추가하십시오.

{
  "compilerOptions": {
    "skipLibCheck": true
  },
}

언급URL : https://stackoverflow.com/questions/46914070/how-to-exclude-d-ts-file-for-typescript-compiler

반응형