2026-02-01
TypeScript Patterns I Use Daily
After years of writing TypeScript professionally, I’ve developed a set of patterns that I reach for in nearly every project. Here are the ones I find most valuable.
Discriminated Unions
One of TypeScript’s most powerful features for modeling state is the discriminated union. Instead of optional fields and null checks everywhere, you can model exactly what states are valid.
type Result<T> =
| { status: "success"; data: T }
| { status: "error"; error: string }
| { status: "loading" };
The satisfies Operator
The satisfies operator lets you validate that a value matches a type without widening it. This is incredibly useful for configuration objects.
Branded Types
When you need to distinguish between values that share the same underlying type, branded types prevent mixing them up at the type level.
Conclusion
These patterns have significantly reduced bugs in my codebases and made refactoring much safer. TypeScript’s type system is incredibly expressive — take advantage of it.