简体   繁体   English

VSCode中的TypeScript错误:“无法写入文件'x',因为它将覆盖输入文件。”

[英]TypeScript errors in VSCode: “Cannot write file 'x' because it would overwrite input file.”

I'm using TypeScript in VSCode to raise the bar on my JavaScript quality. 我在VSCode中使用TypeScript来提高我的JavaScript质量标准。 However, tsconfig.json keeps throwing errors that it cannot write my .js files. 但是,tsconfig.json不断抛出错误,无法写入我的.js文件。 Specifically: 特别:

"Cannot write file 'lib/chart.js' because it would overwrite input file." “无法写入文件'lib / chart.js',因为它将覆盖输入文件。”

I've seen several similar questions here, but they all simply suggest to exclude the .js files. 我在这里看到了几个类似的问题,但它们都只是建议排除.js文件。 However, I actually want TypeScript to show me code warnings for those files. 但是,我实际上希望TypeScript向我显示这些文件的代码警告。

I'm looking for suggestions on how to have TypeScript review my JS files, but not keep throwing errors about not being able to write the input file itself. 我正在寻找有关如何使TypeScript复审我的JS文件的建议,但并不会一直引发关于无法编写输入文件本身的错误。

Note, that this doesn't happen for all my .js files, just some of them. 请注意,这并不是我的所有.js文件都发生的,只是其中的一部分。

Below is my tsconfig.json file. 以下是我的tsconfig.json文件。 Note that all my .js files are in the lib folder. 请注意,我所有的.js文件都在lib文件夹中。

{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true,
        "lib": ["es2018", "dom"]
    },
    "include": [
        "lib"
    ],
    "typeAcquisition": {
        "enable": true
    }
}

Cannot write file 'lib/chart.js' because it would overwrite input file." 无法写入文件'lib / chart.js',因为它会覆盖输入文件。”

Use outDir if you are using allowJs . 如果使用outDir ,请使用allowJs TypeScript will take the input .js files and put a same named one in the outDir . TypeScript将接受输入的.js文件,并将相同名称的文件放在outDir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM