tagged-unions
CommunityExplicit, safe unions for interface states
Software Engineering#typescript#state-management#discriminated-unions#type-system#tagged-unions#exhaustiveness
Authorluyi985
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Many codebases accumulate invalid state representations when using plain interfaces with optional properties. Tagging unions provides explicit relationships and safer narrowing to prevent runtime errors.
Core Features & Use Cases
- Explicit state variants with a literal tag to enable exhaustive checks.
- Safe narrowing through discriminated unions to guarantee correct data per state.
- Real-world example: modeling view states, API responses, or UI modes with distinct data for each variant.
Quick Start
Create a union type with a literal 'type' field for each variant and switch on 'type' to handle every case.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: tagged-unions Download link: https://github.com/luyi985/lyi-bash/archive/main.zip#tagged-unions Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.