Glob support in tsconfig.json

Glob support is here!! Glob support has been one of the most requested features.

Glob-like file patterns are supported two properties "include" and "exclude".

Example

  1. {
  2. "compilerOptions": {
  3. "module": "commonjs",
  4. "noImplicitAny": true,
  5. "removeComments": true,
  6. "preserveConstEnums": true,
  7. "outFile": "../../built/local/tsc.js",
  8. "sourceMap": true
  9. },
  10. "include": [
  11. "src/**/*"
  12. ],
  13. "exclude": [
  14. "node_modules",
  15. "**/*.spec.ts"
  16. ]
  17. }

The supported glob wildcards are:

  • * matches zero or more characters (excluding directory separators)
  • ? matches any one character (excluding directory separators)
  • */ recursively matches any subdirectoryIf a segment of a glob pattern includes only or .*, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default with .js and .jsx if allowJs is set to true).

If the "files" and "include" are both left unspecified, the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true.

If the "files" or "include" properties are specified, the compiler will instead include the union of the files included by those two properties.Files in the directory specified using the "outDir" compiler option are always excluded unless explicitly included via the "files" property (even when the “exclude” property is specified).

Files included using "include" can be filtered using the "exclude" property.However, files included explicitly using the "files" property are always included regardless of "exclude".The "exclude" property defaults to excluding the node_modules, bower_components, and jspm_packages directories when not specified.