Skip to content
GitHub

TypeScript Patterns

Production-ready patterns for building testable, type-safe, and observable TypeScript applications.

Everything starts with a simple function signature:

fn(args, deps)
  • args: What varies per call (userId, input data)
  • deps: Injected collaborators (database, logger, other functions)

This single pattern unlocks testability, composability, and clarity.

Start Learning

Begin with Testing & Testability to understand why these patterns exist and how they solve real problems.

Core Patterns

Learn the fundamental patterns: functions over classes, validation, typed errors, observability, and resilience.

Enforcement

Discover how to enforce patterns through configuration, TypeScript config, and ESLint rules.

Verification

Learn how to verify your patterns work with performance testing and validation.

PatternProblem It SolvesEnforced By
Testing & TestabilityHidden dependenciesfn(args, deps) signature
Functions Over ClassesConstructor bloatPer-function deps
ValidationLying type signaturesZod at the boundary
Typed ErrorsInvisible failuresResult<T, E> types
Composing WorkflowsPartial failuresSagas, parallel ops
Composition PatternsMonolithic growthSmall pieces that combine
ObservabilityOpaque executiontrace() wrapper
ResilienceTransient failuresstep.retry() in workflows
ConfigurationBad startup stateEnv schemas, fail fast
TypeScriptType leaksStrict compiler flags
ESLintPattern driftLint rules that fail builds
PerformanceUnknown bottlenecksLoad tests + chaos tests