【发布时间】:2016-05-03 20:22:16
【问题描述】:
我在运行tsc时遇到问题
error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file.
我的tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"newLine": "LF",
"preserveConstEnums": true,
"pretty": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"typings"
]
}
此问题在以下情况下解决:
- 在
tsconfig中排除index.ts - 运行
tsc index.ts - 在
tsconfig中关闭declaration - 将
index重命名为另一个名字!
在 package.json 中更改 typescript 主文件时我遇到了同样的问题
例如:将 index.ts 重命名为 foo.ts
将package.json 更改为
"typescript": {
"main": "foo.ts"
}
tsc 错误:
error TS5055: Cannot write file 'index.d.ts' because it would overwrite input file.
文件内容无所谓,任何代码内容都有同样的问题!
我能做些什么来修复它?
源码:https://github.com/AliMD/Node.js-Telegram-Bot-API/tree/v0.0.2-0
提前谢谢你。
【问题讨论】:
-
我在
tsconfig临时排除了index.ts来解决这个问题,并在index.ts更改时单独运行tsc index.ts! :( -
也许你在代码中的某个地方引用了
index.d.ts,然后当你编译时,编译器认为index.d.ts是源的一部分,因此抛出该错误。只是一个想法。 -
如果你在没有
"declaration": true的情况下编译会发生什么? -
什么意思?
-
您在 cmets 上没有得分,但您是对的,我不知道答案,但我提出问题/提出建议是为了尝试帮助您解决或找到解决您的问题,直到它解决。别客气。并且 outDir 可以与问题相关,因为它将源与输出分开,然后它不应该抱怨在源文件上写入,也许,只是一个想法,但也许它不会工作,该死,不会'没有得到我宝贵的积分。
标签: typescript