Updated: January 17, 2021
TypeScript has a way of describing a build process as multiple subpieces of a project. This saves from having to build every piece, and instead build independent parts and stitch them together as needed.
In a monorepo environment, multiple packages will have multiple builds and, possibly, refer to those builds amongst each other.
tsconfig.json file can be used, but a problem of independent sources of truth arises. For instance, one project may have a different level of type strictness, or use a different version of Node. Rather than forcing every package to abide by a given rule, it is advantageous to have thin configurations for independent packages, but have them all rely on the more general rules in the root-level
The key to having multiple TS configs coexisting together is in a given package’s
tsconfig file, under the
"composite": true. This tells the compiler that this is one piece of a larger project.
Building a composite set of packages like this will produce a
tsconfig.buildinfo file, which–basically–holds a set of checksums of each file in its current state and when it was last built. By comparing the
signature attributes of a given section within the
buildinfo file, the TS compiler can know when to rebuild that specific piece.