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.
Use the exclude option in your tsconfig. json file to exclude a folder from compilation in TypeScript. The exclude option changes what the include setting finds and defaults to node_modules and bower_components . tsconfig.json. Copied!
The "include" property allows you to include a list of TypeScript files using the glob wildcards pattern. The "exclude" property allows you to exclude a list of TypeScript files using the glob wildcards pattern.
TypeScript includes a default set of type definitions for built-in JS APIs (like Math ), as well as type definitions for things found in browser environments (like document ).
To exclude test files from compilation, but still have them type checked, create a second configuration file, e.g. tsconfig. build. json , which uses the excludes array to exclude your test files from compilation when running the tsc command.
Full example if anyone needs it:
{ "compilerOptions": { ... }, "include": [ "src/**/*" ], "exclude": [ "src/**/*.spec.ts" ] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With