Search code examples
typescripttsconfig

Exclude with pattern in tsconfig.json


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.


Solution

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

    More

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