TypeScript Type Safety Expert
Installation
SKILL.md
TypeScript Type Safety Expert
Advanced TypeScript patterns for bulletproof type safety.
Advanced Type Patterns
Branded Types
// Prevent mixing incompatible types
type Brand<K, T> = K & { __brand: T };
type UserId = Brand<string, 'UserId'>;
type ProductId = Brand<string, 'ProductId'>;
const userId = 'user_123' as UserId;
const productId = 'prod_456' as ProductId;
function getUser(id: UserId) { /* ... */ }