【问题标题】:Adding tsconfig exclude causes "Cannot write file" errors? in VSCode添加 tsconfig exclude 会导致“无法写入文件”错误?在 VS 代码中
【发布时间】:2019-12-07 17:55:10
【问题描述】:

如果我将此exclude 块添加到我的tsconfig.json 文件中:

 "exclude": ["angular-package-format-workspace"]

VSCode 中出现以下错误。如果我删除 exclude 块,它们就会消失(排除块也具有所需的影响 - 所以很好奇为什么 VSCode 会绘制错误):


SON schema for the TypeScript compiler's configuration file

Cannot write file '/home/ole/Github/slice/target/dist/index.d.ts' because it would overwrite input file.ts
Cannot write file '/home/ole/Github/slice/target/dist/index.d.ts' because it would overwrite input file.ts
Cannot write file '/home/ole/Github/slice/target/dist/index.d.ts' because it would overwrite input file.ts

这是我的tsconfig.json 文件:

{
  "compilerOptions": {
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "lib": ["es2017"],                        /* Specify library files to be included in the compilation. */
    "declaration": true,                   /* Generates corresponding '.d.ts' file. */
    "sourceMap": true,                        /* Generates corresponding '.map' file. */
    "outDir": "./target",                     /* Redirect output structure to the directory. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "strictNullChecks": false,                /* Enable strict null checks. */
    "baseUrl": "./",                          /* Base directory to resolve non-absolute module names. */
    "paths": {
      "@fs/*": ["./src/*"],
      "@test/*": ["./test/*"]
    },                                            /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */   
    "plugins": [
      { "transform": "typescript-transform-paths" },
      { "transform": "typescript-transform-paths", "afterDeclarations": true }
    ],
    "rootDirs": ["./src/"],                   /* List of root folders whose combined content represents the structure of the project at runtime. */
    "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "experimentalDecorators": true           /* Enables experimental support for ES7 decorators. */
  },
  "exclude": ["angular-package-format-workspace"]  
}

【问题讨论】:

  • 尝试添加块,保存,然后重新启动 Visual Studio Code。我在使用的文件中遇到了类似的问题,导致 Typescript 出现奇怪的错误
  • 是的 - 做到了 - 谢谢!
  • 太棒了!我发布了我的评论作为对您问题的回答

标签: javascript typescript visual-studio-code


【解决方案1】:

尝试添加块,保存,然后重新启动 Visual Studio Code。

Visual Studio Code 在运行时会保留打开的文件,这可能会与尝试读取/写入文件的其他程序发生冲突。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    相关资源
    最近更新 更多