How to scale a typescript project up or down

Scaling a TypeScript project is rarely about adding code. It is about deciding how much of the type system earns its place at the current size, and being willing to reverse that decision when the size changes in either direction.

Signals that a project should scale up

  • The same object shape is declared in three places.
  • A union has grown past four members and functions handle only some of them.
  • A single file needs a table of contents to navigate.
  • Unrelated features break whenever one type changes.

Any one of these is an argument, not a verdict. Two together usually mean the structure has fallen behind the code.

Signals that it should scale down

  • A generic wrapper exists for a single call site.
  • A conditional type needs three people to read it before a change.
  • Adding one field to an entity touches four files.
  • Compiler output is slow enough that you stop running it.

Abstraction is a cost paid on every future change. When the benefit is a saved duplicate that no longer exists, the cost is all that remains.

The honest test is maintenance cost: count how many places you must edit to add one field, then decide whether that number is acceptable for the project as it exists today rather than as you hope it will be.

Growing without bloating the type surface

Split by change, not by layer. Move code that changes together into one module and keep its types beside it. Export the narrowest thing callers need, because every exported type is a promise you will maintain.

Barrel files that re-export everything feel tidy and make dependencies invisible. Prefer explicit imports until the project has a real reason to hide its internals, and when it does, make that boundary deliberate rather than a habit.

Shrinking without breaking callers

Start at the leaves. Inline a single-use abstraction, replace a generic parameter with the concrete type you always pass, and delete utility types that exist only because they were fashionable. Run the compiler after each change and let it point at the callers that noticed.

Shrinking is safest when the public types stay stable while the implementation collapses underneath them. Do the collapse first, then remove what is genuinely unused.

Decide what counts as public

Most projects have a boundary even when nobody named it: a package entry point, a client wrapper, a set of components. Everything inside can change freely; everything outside deserves a stable type and a note about the change.

Once that boundary is written down, both directions get easier. Growth means adding inside it, and shrinking means deleting inside it, without negotiating every field with the rest of the team.

Write the boundary somewhere a newcomer will find it, even if that is one paragraph at the top of the entry file. A rule nobody can locate is a rule that only applies to the person who made it.

Scale on evidence, not ambition. A generic that saves three call sites is worth its weight; a type system designed for growth that never arrives is simply a second project to maintain.