ts-best-practices-functional
Installation
SKILL.md
ts-best-practices-functional
Refactor or author TypeScript using a functional doctrine: factories over classes, Result<T,E> over exceptions, immutable state via spread/map/filter, and pure functions composed in pipelines.
Core principles
| Prefer | Over | Why |
|---|---|---|
| Data transformations | Mutations | Predictable, easier to reason about |
| Functions | Methods | No this binding issues |
| Composition | Inheritance | Mix behaviors without coupling |
| Explicit | Implicit | State passed in, not hidden |
| Factories | Classes | Closure-encapsulated state, no new |
Patterns
Factories over classes
Use a factory function returning an interface to encapsulate state. Closures make the state truly private; no this to bind.