← blog

typescript patterns for large-scale applications

February 5, 2025 · 10 min read

TypeScript's type system is Turing-complete. These patterns exploit that power to catch bugs at compile time instead of runtime.

discriminated unions for state machines

Modelling async state as a discriminated union eliminates impossible state combinations...

branded types

A UserId is not just a string. Branding primitive types prevents accidental misuse across domain boundaries...

utility type compositions

Combining Pick, Omit, Partial, and Required creates precise types without duplication...

const assertions

Using "as const" on config objects infers literal types, enabling exhaustive switch statements...

typescript · architecture · dx

more

optimising postgresql for heavy read workloadsbuilding autonomous ai agents with langchain & reactmulti-agent workflows with crewai and autogen