typescript-patterns
SKILL.md
TypeScript Patterns
Rules (always apply)
| Pattern | Do | Don't |
|---|---|---|
| Object shapes | interface |
type |
| Composition | interface extends |
type & |
| Unions | discriminated, <10 members | bag of optionals |
| Constants | as const objects |
enum |
| Imports | import type { T } |
import { type T } |
| Return types | explicit on exports | infer (except JSX) |
| Validation | satisfies |
manual annotation |
| Data | readonly default |
mutable default |
| Mutation | spread operator | direct mutation |
| Async | Promise.all when independent |
sequential awaits |