我一直收到以下错误:
Error Code: TS5055
Cannot write file C:/project/dir/server.js' because it would overwrite input file.
Project: TypeScript/JavaScript Virtual Projects
我甚至尝试将我的输入文件名更改为nodeserver.js
,过了一段时间我得到了同样的错误:
Error Code: TS5055
Cannot write file C:/project/dir/nodeserver.js' because it would overwrite input file.
Project: TypeScript/JavaScript Virtual Projects
如何找出试图覆盖它的组件?
我注意到该文件的BuildAction
设置为Compile
,“发布”设置为true。这可能是原因吗?关闭。{1}} .js文件的含义是什么?我不会得到任何错误检查吗?
我的tsconfig.json
Compile
我的package.json
{
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react"
},
"exclude": [
"node_modules",
"public",
"server.js",
"Scripts/typings/main",
"Scripts/typings/main.d.ts"
],
"filesGlob": [
"./src/**/*.ts",
"./src/**/*.tsx"
]
}
答案 0 :(得分:1)
似乎打字稿编译器尝试转换所有内容,包括已经是javascript的文件。解决方案是在compilerOptions中添加一个新字段 outDir ,所以看起来像这样:
{
...
"compilerOptions": {
...
"outDir": "generated"
}
...
}