typescript 在 tsconfig.json 中使用模式排除

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36475736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:23:54  来源:igfitidea点击:

Exclude with pattern in tsconfig.json

typescripttsconfig

提问by Nick Tsitlakidis

Is there any way to add a pattern in the exclude property of a tsconfig file or is it only able to support directories?

有什么方法可以在 tsconfig 文件的 exclude 属性中添加模式,还是只能支持目录?

I'm trying to exclude all my test files from compilation so I was wondering if I can use something like this :

我试图从编译中排除我所有的测试文件,所以我想知道我是否可以使用这样的东西:

src/**/*.spec.ts

Seems like it doesn't work though.

虽然它似乎不起作用。

采纳答案by basarat

Globs work in Typescript 2.0+. You would do "exclude" : ["src/**/*.spec.ts"]in your tsconfig.json.

Glob 在 Typescript 2.0+ 中工作。你会"exclude" : ["src/**/*.spec.ts"]在你的tsconfig.json.

More

更多的

https://basarat.gitbook.io/typescript/content/docs/project/files.html

https://basarat.gitbook.io/typescript/content/docs/project/files.html

回答by sherb

Full example if anyone needs it:

如果有人需要它的完整示例:

{
  "compilerOptions": {
    ...
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "src/**/*.spec.ts"
  ]
}