exclusive-or-properties

Installation
SKILL.md

Use Optional Never Properties to Model Exclusive Or

Overview

Sometimes you need a type where exactly one of several properties must be present, but not more than one. This "exclusive or" (XOR) pattern is common in component props, API parameters, and configuration objects. Using optional properties with never types enforces this constraint at compile time.

This technique provides better type safety than unions of objects and clearer intent than runtime checks.

When to Use This Skill

  • Exactly one of several properties must be present
  • Modeling mutually exclusive configuration options
  • Component props with alternative configurations
  • API parameters that have exclusive variants
  • Preventing invalid combinations of properties

The Iron Rule

Use optional never properties to enforce "exactly one of" constraints. Each variant makes its property required and others never.

Related skills
Installs
11
GitHub Stars
2
First Seen
Feb 3, 2026