typescript-functional-patterns
SolidFunctional programming patterns for reliable TypeScript. Use when modeling state machines, discriminated unions, Result/Option types, branded types, or building type-safe domain models.
AI & Automation 46 stars
4 forks Updated 1 months ago MIT
Install
Quality Score: 81/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Functional Patterns for Reliable TypeScript
Build reliable systems using Algebraic Data Types (ADTs), discriminated unions, Result/Option types, and branded types. These patterns enable the compiler to prove correctness, prevent runtime errors, and make illegal states unrepresentable.
## Why Functional Patterns?
**Reliability through types**: Use the type system to encode business rules, making invalid states impossible to construct. The compiler becomes your safety net, catching errors at build time rather than runtime.
**Key benefits:**
- Exhaustiveness checking prevents missing cases
- Impossible states become unrepresentable
- Business logic encoded in types, not runtime checks
- Refactoring becomes safe and mechanical
- Self-documenting code through types
## Quick Reference
For detailed patterns and examples, see:
- [ADTs (Algebraic Data Types)](./references/adts.md) - Sum types, product types, discriminated unions
- [Option & Result](./references/option-result.md) - Type-safe error handling and nullable values
- [Branded Types](./references/branded-types.md) - Smart constructors and nominal typing
- [Migration Guide](./references/migration-guide.md) - Step-by-step adoption playbook
## Core Patterns Overview
### 1. Discriminated Unions (Sum Types)
Model "one of several variants" with exhaustive pattern matching:
```typescript
type PaymentMethod =
| { kind: "card"; last4: string; brand: string }
| { kind: "ach"; accountNumber: string; routingNumber: string...
Details
- Author
- martinffx
- Repository
- martinffx/atelier
- Created
- 8 months ago
- Last Updated
- 1 months ago
- Language
- TypeScript
- License
- MIT
Integrates with
Bundled in these plugins
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Listed
typescript-patterns
TypeScript type system patterns — strict mode, generics, discriminated unions, branded types, inference, utility types.
1 Updated yesterday
jjackkun AI & Automation Listed
typescript-patterns
Use for TypeScript in an existing project when choosing idiomatic types, discriminated unions, typed errors, promises, concurrency, or async design.
5 Updated 2 days ago
lawzava AI & Automation Listed
typescript-best-practices
TypeScript idioms and type-safety patterns: discriminated unions, branded types, narrowing, boundary validation. Use when reading, writing, or reviewing any .ts or .tsx file.
5 Updated 5 days ago
itsvedantkumar