This isn't a list of TypeScript tricks. It's a list of the patterns that showed up, unprompted, in every large TypeScript codebase I've worked in or reviewed.
1. Discriminated Unions for State Machines
The moment you have state that can be in one of several distinct shapes, reach for a discriminated union instead of an object with optional fields.
TypeScript will force you to handle all cases when you switch on status.
That's the feature.
2. satisfies for Config Objects
satisfies lets you validate a value against a type while preserving
the literal type of the value itself.
3. Branded Types for IDs
When you have multiple ID types (userId, postId, orderId), a plain string
type won't stop you from accidentally passing the wrong one.
4. Omit + Pick in API Layers
Rather than duplicating types between your DB model and API response, compose them.
The Underlying Principle
Good TypeScript isn't about making the type system do gymnastics. It's about encoding your domain's rules into types so the compiler can catch the bugs your brain misses at 11pm.
Simple, explicit types. Discriminated unions. Avoid any. That's most of it.
Jason Lima
Software engineer. I write about building systems, the craft of code, and lessons learned from shipping real products. Say hello →
Related reading
The Hidden Cost of 'Simple' Architecture Decisions
Every architecture decision you make in the first six months will still be there in year three. Here's how to think about the ones that compound.
On Writing Code That Explains Itself
Self-documenting code is not about avoiding comments — it's about making the code itself tell the story clearly enough that comments become optional.