typescript-patterns
Installation
SKILL.md
Advanced TypeScript Patterns
Production-grade TypeScript patterns for building type-safe, maintainable, and scalable applications. This skill covers generics, utility types, conditional types, discriminated unions, branded types, and more.
1. Advanced Generics with Constraints
Basic Generic Constraints
// Constrain T to objects that have a .length property
function getLength<T extends { length: number }>(item: T): number {
return item.length;
}