Agent skill · software engineering · erichowens
typescript-advanced-patterns
Advanced TypeScript type system patterns for production codebases. [What: branded types for nominal typing, discriminated unions, template literal types, conditional types, the infer keyword,
Why this skill is useful
Provides advanced TypeScript patterns that enhance type safety and eliminate runtime bugs, which the AI wouldn't reliably generate on its own.
What it needs
About 9k tokens when loaded. Last updated 2026-07-14. 180 stars on the source repository.
What this skill does
TypeScript Advanced Patterns Advanced type system patterns that eliminate runtime bugs by encoding constraints at compile time. When to Use Activate on: "branded types", "nominal typing", "discriminated union", "template literal types", "conditional types", "infer keyword", "satisfies operator", "const assertion", "Zod inference", "exhaustive switch", "type-safe event emitter", "mapped types", "utility types", "generic constraints", "type narrowing", "as const" NOT for: Basic TypeScript syntax React component prop types General JavaScript patterns Decision Tree: Which Advanced Pattern for Your Problem? Core Patterns 1. Branded Types (Nominal Typing) TypeScript's structural type system means UserId and string are assignable to each other. Branded types add a phantom brand that makes them incompatible. See references/branded-types.md for Zod integration and database model patterns. 2. Discriminated Unions with Type Narrowing The kind (or type, tag) field is the discriminant. TypeScript narrows the union when you check it. With exhaustive checking — if a new variant is added and the switch is not updated, it's a compile error: 3. Template Literal Types Combine string literals at type level to create precise types for string-based APIs: 4. Conditional Types with infer infer extracts a type from within another type during conditional type evaluation. 5. The satisfies Operator (TypeScript 4.9+) satisfies validates a value against a type without widening it. You get both type checking AND the most specific inferred type. 6. Zod Schema Inference Zod validates at runtime and provides TypeScript types for free. Never write a type + validator separately. See references/type-safe-patterns.md for type-safe event emitters, builder pattern, and exhaustive checking utilities. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills erichowens/typescript-advanced-patterns