senrecep/tsentials/tsentials-union
Claude Code and agent skill by senrecep/tsentials
- community
Checking that the SKILL.md file is still in the repository.
Use when a value can be one of several distinct tagged types — Union<T> as a compile-time-safe discriminated union with Union.match() for exhaustive pattern matching, Union.is() for type guards, and Union.of() for construction.
Install
npx vskill@latest install senrecep/tsentials/tsentials-unionSKILL.md
tsentials/union
Union<T> is a tag-based discriminated union with exhaustive pattern matching. Replaces object-typed returns and unsafe casting.
Installation
Import
Defining a Union
Creating Values
Assign a fresh literal with as, not : — annotating the variable with : PaymentResult narrows it down to whichever member the literal matches, which breaks Union.match exhaustiveness the moment you use that variable:
Union.of(tag, value) also constructs a value, but its type parameter can't be inferred from a Union<T> alias — you must spell out the full record shape T explicitly:
The as form above is shorter and equally type-safe — prefer it unless you specifically need Union.of.
Exhaustive Pattern Match
Type Guard
Extracting Value
Typical Usage — service return type
Union\<T\> vs Result\<T\>
| Use | When | |
|---|---|---|
Result<T> | Binary success/failure — one value OR one-or-more errors | |
Union<T> | Multiple distinct outcome types — each branch carries different typed data |
Best Practices
- Use
Union<T>overResult<T>when failure branches carry distinct, typed payloads - Always use
Union.match()— it enforces exhaustiveness at compile time Union.is()+ accessing.valueis the escape hatch whenmatch()is too verbose- Avoid
any-typed union members — defeats type safety - For simple nullable values, prefer
Maybe<T>overUnion<{ some: T; none: {} }>
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.well-known/agent-skills/tsentials-union/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/senrecep/tsentials/tsentials-union)