我正在使用Typescript
,在tsconfig.json
中出现此错误:
无法写入文件'c:/michael/Documents/razor/lib/client.d.ts',因为它会覆盖输入文件。
这是我的tsconfig.json
内容:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "Node",
"sourceMap": true,
"outDir": "./lib",
"removeComments": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"declaration": true
},
"exclude": [
"node_modules",
"test"
]
}
如您所见,我已启用declaration: true
来导出d.ts
文件。
这是我的项目文件夹结构:
/lib
/node_modules
/src
/test
.gitignore
.npmignore
razor-1.0.0.tgz
package.json
packages-lock.json
readme.md
tsconfig.json
如果我尝试运行tsc -p
,则无法编译,因此每次必须手动删除包含已编译项目的文件夹lib
时。
我该如何解决?
答案 0 :(得分:2)
TypeScript在编译时正在从lib
目录中拾取文件。因此,该错误。尝试将lib
添加到exclude
数组中。