如何使用--outDir TypeScript编译器选项 [英] How to use --outDir TypeScript compilerOptions

查看:63
本文介绍了如何使用--outDir TypeScript编译器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,编译器抱怨以下问题:无法写入文件"path/file.json",因为它会覆盖输入文件.我做了一些挖掘,大多数解决方案建议使用outDir进行修复.该解决方案工作正常,但我不确定要传递给哪个文件夹.现在,我将其设置如下,并且编译器停止抱怨:

I'm facing an issue where the compiler complains about the following: Cannot write file 'path/file.json' because it would overwrite input file. I did some digging and most solutions suggest to use outDir to fix it. 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",

我不太确定这是否是个好主意,因为我基本上是在通过它本身.Json只是我正在读取的对象,并且正在使用Aurelia项目.任何提示或信息将不胜感激.

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. Any tips or information will be greatly appreciated.

推荐答案

我怀疑您不希望编译此json文件吗?也许只是将其添加到tsconfig.json中的排除"全局文件中,以便tsc不会对其进行处理?

I suspect you don't want this json file to be compiled? Maybe just add it to the "exclude" glob in your tsconfig.json so tsc doesn't process it?

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

我通常把我分成
src/
dist/

I usually split mine into
src/
dist/

然后我的tsconfig会像

Then my tsconfig would have something like

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

这篇关于如何使用--outDir TypeScript编译器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆