Type reducer actions cleanly with a union.
Section: TypeScript with State and Refs
Discriminated union reducer actions
tsx
tsx
type Action =
| { type: 'increment' }
| { type: 'decrement' }
| { type: 'reset'; payload: number };Explanation
Discriminated unions give exhaustive reducer switch safety.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing TypeScript with State and Refs