typescript-best-practices
Installation
SKILL.md
TypeScript Best Practices
Follows the type, error, and assertion law in code-law. This skill covers language-specific idioms only.
Make Illegal States Unrepresentable
Use the type system to prevent invalid states at compile time.
Discriminated unions for mutually exclusive states:
// Good: only valid combinations possible
type RequestState<T> =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: T }
| { status: 'error'; error: Error };