branded-types
Installation
SKILL.md
Consider Brands for Nominal Typing
Overview
Add phantom types to distinguish semantically different values.
TypeScript uses structural typing, but sometimes you need nominal typing - values that are distinct because you SAY they are, not because they have different shapes. Brands let you do this without runtime overhead.
When to Use This Skill
- Distinguishing paths (absolute vs relative)
- Attaching units to numbers (meters, seconds)
- Preventing 2D/3D vector mix-ups
- Marking validated/sanitized strings
- Creating type-safe identifiers