相关疑难解决方法(0)

TypeScript错误:无法写入文件'index.d.ts',因为它将覆盖输入文件

我跑步时有问题 tsc

error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file.
Run Code Online (Sandbox Code Playgroud)

我的tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "newLine": "LF",
    "preserveConstEnums": true,
    "pretty": true,
    "experimentalDecorators": true
  },

  "exclude": [
    "node_modules",
    "typings"
  ]
}
Run Code Online (Sandbox Code Playgroud)

该问题在以下情况下得以解决:

  1. 排除index.tstsconfig
  2. tsc index.ts
  3. 关闭declaration在关闭tsconfig
  4. 重命名index为另一个名称!


例如,在package.json中更改打字稿主文件时,我遇到了相同的问题:将index.ts重命名为foo.ts

更改package.json

"typescript": {
  "main": "foo.ts"
}
Run Code Online (Sandbox Code Playgroud)

tsc错误:

error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file. …
Run Code Online (Sandbox Code Playgroud)

typescript

6
推荐指数
3
解决办法
8595
查看次数

标签 统计

typescript ×1