Skip to main content

Transitions

A type which is used to define valid states and transitions for a state machine based on FSM.

Example

Ts
type LightColor = 'Green' | 'Amber' | 'Red';const trafficLightTransitions: Transitions<LightColor> = {  Green: {    to: ['Amber'],  },  Amber: {    to: ['Red'],  },  Red: {    to: ['Green'],  },};

The mergeStrategy property defines how to handle the merging of states when one set of transitions is being merged with another (as in the case of defining a OrderProcess)

Signature
type Transitions<State extends string, Target extends string = State> = {    [S in State]: {        to: Readonly<Target[]>;        mergeStrategy?: 'merge' | 'replace';    };}
Was this chapter helpful?
Report Issue
Edited Feb 4, 2026·Edit this page