提问者:小点点

无法使用声明覆盖目录


我正在使用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

我该怎么解决这个问题?


共1个答案

匿名用户

编译时,TypeScript正在从lib目录中拾取文件。 因此,这个错误。 尝试将lib添加到exclude数组。