Skip to content

InputMapFromUnion

InputMapFromUnion<TEvent> = { [E in TEvent as E["type"]]: [event: E] }

Defined in: types.ts:293

Builds an input payload map from a discriminated event union, matching the common “dispatch the whole event” pattern: handle(event.type, event).

TEvent extends object

type TrafficLightEvent =
  | { type: "emergency"; severity: number }
  | { type: "pedestrianRequest"; crossingId: string };

type TrafficLightInputs = InputMapFromUnion<TrafficLightEvent>;
// => { emergency:         [event: { type: "emergency"; severity: number }];
//      pedestrianRequest: [event: { type: "pedestrianRequest"; crossingId: string }] }