Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exclude subdirectories in tsconfig.json

I have installed TypeScript 1.8.2, and using Visual Studio 2015. I have a simple project where I have problems excluding folders from the tsconfig.json file. The problem is I would like to exclude the file typings/browser.d.ts and the folder typings/browser. But this is not the case?

I have no problems excluding a subfolder, but not a sub-subfolder?

[NOTE] I just realized the problem is only when I build from Visual Studio! If i build with tsc from the command line, there's no problem. Could I have another version of TypeScript in Visual Studio? How can I check this?

This is my tsconfig.json:

{   "compilerOptions": {     "target": "es5",     "module": "commonjs",     "moduleResolution": "node",     "sourceMap": true,     "emitDecoratorMetadata": true,     "experimentalDecorators": true,     "removeComments": false,     "noImplicitAny": false   },   "exclude": [     "node_modules",     "public",     "typings/browser",     "typings/browser.d.ts"   ] } 

I have a bigger project, where I use jspm and need to exclude the jspm package folder, which is located as a subfolder to public.

like image 626
DNRN Avatar asked Feb 26 '16 09:02

DNRN


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 json?

The include and exclude properties take a list of glob-like file patterns. The supported glob wildcards are: * matches zero or more characters (excluding directory separators) ? matches any one character (excluding directory separators)

What is include in Tsconfig json?

Include – It is a property that allows you to include a list of TypeScript files using the glob wildcards pattern. “include”: [ “src/**/*” ] Exclude – It is a property that allows you to exclude a list of TypeScript files using the glob wildcards pattern.

How do I ignore files in TypeScript?

To ignore all errors in a TypeScript file, we can add the // @ts-nocheck comment.


2 Answers

Try with:

 "exclude": [      "node_modules",      "public",      "typings/browser.d.ts",      "typings/browser/**"  ] 
like image 106
Amid Avatar answered Oct 26 '22 14:10

Amid


I just installed and tested the latest version of TypeScript for Visual Studio 2015 (1.8.6 at the moment), and I can confirm that this problem has been fixed in the latest release.

https://www.microsoft.com/en-us/download/details.aspx?id=48593

[Edit] Be sure to also do an npm update -g typescript

like image 21
SourceSimian Avatar answered Oct 26 '22 15:10

SourceSimian