TypeScript Patterns I Use Every Day

TypeScript Patterns I Use Every Day

IO

Isaac Oyelowo

@AlmightyScopes

January 28, 2026
6 min read
0%

Practical TypeScript patterns that have improved my code quality and developer experience over the years.

TypeScript Patterns I Use Every Day

After years of writing TypeScript, these are the patterns I reach for most often.

1. Discriminated Unions

Perfect for handling different states in your application:

typescript
type AsyncState<T> =
  | { status: 'idle' }
  | { status: 'loading' }
  | { status: 'success'; data: T }
  | { status: 'error'; error: Error };

2. Branded Types

Add type safety to primitive values:

typescript
type UserId = string & { __brand: 'UserId' };
type PostId = string & { __brand: 'PostId' };

3. Const Assertions

Get literal types from objects:

typescript
const ROUTES = {
  home: '/',
  about: '/about',
} as const;

4. Utility Types

Master the built-in utility types like Pick, Omit, Partial, and Required.

These patterns have saved me countless hours of debugging and made my code more maintainable.

IO

Written by Isaac Oyelowo

Obsessive problem-solver disguised as a software engineer. I write about building products, software architecture, and lessons learned along the way.

Stay in the Loop

Get notified when I publish new articles. No spam, just quality content about software development and building products.

No spam. Unsubscribe anytime.

Discussion

Join the Conversation

Have thoughts on this post? I'd love to hear from you! Comments are coming soon via GitHub Discussions.

Share your thoughts on Twitter