Exclude with pattern in tsconfig.json

Nick Tsitlakidis picture Nick Tsitlakidis · Apr 7, 2016 · Viewed 25.3k times · Source

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

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.

Answer

sherb picture sherb · Oct 17, 2017

Full example if anyone needs it:

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