Typescript: "exclude" with glob does not exclude folders

Created on 8 Dec 2016  路  4Comments  路  Source: microsoft/TypeScript

TypeScript Version: 2.1.4 / nightly (2.2.0-dev.20161208)

Steps to reproduce:

  1. Create empty folder and install TypeScript 2.1.4 (or @next)
mkdir test && cd test
npm install [email protected]
  1. Create empty tsconfig.json
./node_modules/.bin/tsc --init
  1. Add "exclude" to tsconfig.json like this:
"exclude": ["**/node_modules"]
  1. Create empty ts file:
touch test.ts
  1. Run the compiler
./node_modules/.bin/tsc

Expected behavior:
Compile successfully.

Actual behavior:
A lot of errors in node_modules/typescript folder

The same source code compiles fine on TypeScript 2.1.1.

More tests:
If I change "exclude" to ["node_modules"] the compilation passes without errors. But if I place "node_modules" in a sub-folder it is not excluded neither by ["node_modules"] nor by ["**/node_modules"] and it leads to errors during the compilation.

Bug VS Code Tracked

Most helpful comment

use "exclude": ["**/node_modules/*"] instead.

All 4 comments

use "exclude": ["**/node_modules/*"] instead.

@mhegazy Thanks!

Created this https://github.com/Microsoft/TypeScript/issues/12824 to find out which behaviour is consistent and it should be documented carefully.

@rbuckton We've seen a number of reports of this issue on the VSCode side. I'm planning to update our documentation to use the "exclude": ["**/node_modules/*"] pattern

Can we please look into this for TS 2.5 as well

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siddjain picture siddjain  路  3Comments

weswigham picture weswigham  路  3Comments

blendsdk picture blendsdk  路  3Comments

wmaurer picture wmaurer  路  3Comments

uber5001 picture uber5001  路  3Comments