Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 853
Nick Tsitlakidis Avatar asked Apr 07 '16 12:04

Nick Tsitlakidis


People also ask

What is exclude in Tsconfig json?

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!

What is include and exclude in Tsconfig?

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.

What is Lib in Tsconfig json?

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 ).

How do I ignore test files in TypeScript?

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.


1 Answers

Full example if anyone needs it:

{   "compilerOptions": {     ...   },   "include": [     "src/**/*"   ],   "exclude": [     "src/**/*.spec.ts"   ] } 
like image 166
sherb Avatar answered Sep 20 '22 11:09

sherb