简体   繁体   English

如何使用--outDir TypeScript编译器选项

[英]How to use --outDir TypeScript compilerOptions

I'm facing an issue where the compiler complains about the following: Cannot write file 'path/file.json' because it would overwrite input file. 我遇到一个问题,编译器抱怨以下问题:无法写入文件“ path / file.json”,因为它会覆盖输入文件。 I did some digging and most solutions suggest to use outDir to fix it. 我做了一些挖掘,大多数解决方案建议使用outDir进行修复。 That solutions works fine but I'm not sure what folder to pass to it. 该解决方案工作正常,但我不确定要传递给哪个文件夹。 Right now I have it set up as follows and the compiler stopped complaining: 现在,我将其设置如下,并且编译器停止抱怨:

outDir: "path/file.json",

I'm not too sure if that's a good idea because I'm basically passing it itself. 我不太确定这是个好主意,因为我基本上是通过它本身。 The Json is just an object that I'm reading from and I'm using an Aurelia project. Json只是我正在读取的对象,并且正在使用Aurelia项目。 Any tips or information will be greatly appreciated. 任何提示或信息将不胜感激。

我的文件夹结构

I suspect you don't want this json file to be compiled? 我怀疑您不希望编译此json文件? Maybe just add it to the "exclude" glob in your tsconfig.json so tsc doesn't process it? 也许只是将其添加到tsconfig.json中的“排除”全局文件中,以便tsc不对其进行处理?

https://www.typescriptlang.org/docs/handbook/tsconfig-json.html https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

I usually split mine into 我通常把我分成
src/ SRC /
dist/ DIST /

Then my tsconfig would have something like 然后我的tsconfig会像

{
  "compilerOptions": {
    "outDir": "dist"
  },
  "include": [
    "src/**/*"
  ],
}

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

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