#cli #typescript #monorepo


Enumerate files used in the TypeScript compilation

13 stable releases (3 major)

4.2.1 Feb 10, 2023
4.2.0 Feb 9, 2023
3.2.0 Feb 8, 2023
2.0.4 Jan 14, 2023
1.0.0 Nov 13, 2022

#2252 in Command line utilities

Download history 6/week @ 2022-11-23 10/week @ 2022-11-30 6/week @ 2022-12-07 5/week @ 2022-12-14 13/week @ 2022-12-21 18/week @ 2022-12-28 52/week @ 2023-01-04 31/week @ 2023-01-11 13/week @ 2023-01-18 10/week @ 2023-01-25 13/week @ 2023-02-01 211/week @ 2023-02-08 35/week @ 2023-02-15 4/week @ 2023-02-22 8/week @ 2023-03-01 7/week @ 2023-03-08

58 downloads per month

ISC OR Apache-2.0

310 lines


Build Status

tsconfig-includes enumerates files used in the TypeScript compilation process for monorepo packages. While tsc --listFilesOnly only lists input files in the target package, tsconfig-includes lists input files in the target package and all of its internal dependencies. You can use this list to determine when inputs to a package has changed, to decide whether to rebuild the package or used a cached version.


Enumerate source code files used by the TypeScript compiler during compilation. The return value is a list of relative paths from the monorepo root, sorted in alphabetical order.

There are two methods of calculating this list of files: the exact way, and using an estimation.

The exact method uses the TypeScript compiler's listFilesOnly flag as the source of truth. We do not try to reimplement this algorithm independently because this list requires following import statements in JavaScript and TypeScript code. From the tsconfig exclude documentation:

Important: exclude only changes which files are included as a result of the include setting. A file specified by exclude can still become part of your codebase due to an import statement in your code, a types inclusion, a /// <reference directive, or being specified in the files list.

The TypeScript compiler is a project where the implementation is the spec, so this method of enumeration trades the runtime penalty of invoking the TypeScript compiler for accuracy of output as defined by the "spec".

The estimation method uses the list of globs from the include property in a package's tsconfig.json file to calculate the list of source files.

This estimation is currently imprecise (and likely to stay that way) -- it makes a best attempt to follow the exclude or file-type based rules:

If a glob pattern doesn’t include a file extension, 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).

without any guarantee of exhaustive compatibility.

Additionally, this method performs no source-code analysis to follow imported files.

You might want to use the estimation method if speed is a concern, because it is several orders of magnitude faster than the exact method.


~202K SLoC