【问题标题】:Cannot write file 'index.d.ts' because it would overwrite input file - but it is(?) excluded无法写入文件 \'index.d.ts\',因为它会覆盖输入文件 - 但它(?)被排除在外
【发布时间】:2022-10-02 17:20:58
【问题描述】:

我收到此错误:

error TS5055: Cannot write file \'index.d.ts\' because it would overwrite input file.

但文件是(应该是?)排除在外通过我的tsconfig.json

{
  \"compilerOptions\": {
    \"alwaysStrict\": true,
    \"esModuleInterop\": true,
    \"declaration\": true,
    \"module\": \"commonjs\",
    \"noImplicitAny\": true,
    \"noImplicitThis\": true,
    \"noImplicitReturns\": true,
    \"target\": \"es2017\",
    \"strict\": true,
    \"strictBindCallApply\": true,
    \"strictFunctionTypes\": true,
    \"strictNullChecks\": true,
    \"strictPropertyInitialization\": true
  },
  \"exclude\": [\"*.d.ts\"],
  \"include\": [\"*.ts\", \"test/*.ts\"]
}

我错过了什么?

    标签: typescript tsconfig


    【解决方案1】:

    您应该有一个不同的输出目录并排除输出目录,以便输入文件不会在现有文件中覆盖/冲突。 希望以下配置有助于解决问题。

    {
        "compileOnSave": true,
        "compilerOptions": {
            "outDir": "./built"
            // ..... others config
        },
        "exclude": [
          "*.d.ts",
          "./built/" // This is what fixed it!
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-08
      • 2013-09-30
      • 2018-07-06
      • 2012-04-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多