1

Any difference between these 2 in tsconfig.json?

"include": ["src"]

"include": ["src/**/*"]

Every example I can find uses the second version, but I'm seeing in my repo that there is no difference. Is there?

  • Does this answer your question? [What is the \*\* glob character?](https://stackoverflow.com/questions/32604656/what-is-the-glob-character) – jsejcksn Apr 18 '23 at 21:22
  • If you aren't observing any behavioral difference, then it's because you don't have any candidate compilation files in nested directories. – jsejcksn Apr 18 '23 at 21:23

1 Answers1

1

The documentation says:

include Specifies an array of filenames or patterns to include in the program. These filenames are resolved relative to the directory containing the tsconfig.json file.

Source: https://www.typescriptlang.org/tsconfig#include

So, according to the docs it is an array of files and not files or directories.

Even if it also works for directories because of some undocumented way of using that value by the compiler (which I am not even sure it does, see the comments to you question) I would not use just the directory name to save five characters, because if you are using an undocumented functionality then you always risk that some new version will go out that removes this undocumented functionality, technically not even being a breaking change.

In other words, the shorter version may work, but if it is not compatible with the official documentation then it should not be relied upon in the long term.

rsp
  • 107,747
  • 29
  • 201
  • 177