question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How tsconfig exclude pattern should actually work

See original GitHub issue

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Say we have a following structure to specially to test exclude pattern:

/node_modules
  /module/some.ts
nested/
  /node_modules
    /module/some.ts
  /deep-nested/
    /node_modules
      /module/some.ts

Will check this using tsc --listFiles

How exclude patterns work:

  1. “node_modules” - will exclude only /node_modules/module/some.ts
  2. “*/node_modules” (the same effect as /node_modules/") - will exclude only /nested/node_modules/module/some.ts
  3. “**/node_modules” - will exclude nothing
  4. “**/node_modules/*” - will exclude everything (also nested, deep-nested)

Some behaviour seem strange to me

  • why in case 3 it excludes nothing (considering case 2 works)?
  • by default (if exclude not specified) case 1 will be effective, shouldn’t it be 4) which excludes node_modules in nested folders as well?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wclrcommented, Dec 12, 2016

Yes but I think default should provide smart defaults, and I think if Ts so smart that event excludes three most common PM’s fiolders (node_modules, bower_components, jspm_modules), it could also be smart enough to do it for nested folders as well.

0reactions
mhegazycommented, Dec 12, 2016

I posted there, also if first point (that “/node_modules"doesn’t work) is bug, there is second point about default exclusion pattern: currntly it is “node_modules/*” shouldn’t it be "/node_modules/*”?

possibly would consider it. the defaults are not meant to be comprehensive thought. it is just a starting point to get most users covered. you can always add additional ones by defining your own exclude patterns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude using a pattern in tsconfig.json in TypeScript
Use wildcard characters to exclude using a pattern in tsconfig.json . The exclude array in the tsconfig.json file supports wild card characters to...
Read more >
Exclude with pattern in tsconfig.json - typescript - Stack Overflow
Exclude with pattern in tsconfig.json · 1 · 1 · Adding them in filesGlob will cause the files list to appear and I'm...
Read more >
TSConfig Reference - Docs on every TSConfig option
Specifies an array of filenames or patterns that should be skipped when resolving include . Important: exclude only changes which files are included...
Read more >
Configuring TypeScript compiler - inDepthDev
It's used to control the output directory structure alongside with outDir . If you want to exclude some files or folders from the...
Read more >
Understanding TypeScript Configuration Options
You can specify the files not to be compiled in the program using an array of filenames or the glob pattern. Normally it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found