Skip to content

InputNamesOf

InputNamesOf<TStates> = Exclude<{ [S in keyof TStates]: keyof TStates[S] & string }[keyof TStates], SpecialStateKeys>

Defined in: types.ts:59

Extracts input names as a string literal union from a states config object. Collects all handler keys across ALL states, then strips out lifecycle hooks and special keys (_onEnter, _onExit, _child, *).

This is what flows into handle(inputName) to provide compile-time validation of input names.

TStates

type I = InputNamesOf<{
  idle:    { start: "running", reset: fn };
  running: { pause: "paused", stop: "idle" };
}>;
// => "start" | "reset" | "pause" | "stop"

How it works:

  1. { [S in keyof TStates]: keyof TStates[S] & string } — maps each state to the union of its handler key names
  2. [keyof TStates] — collapses the mapped type into a flat union of ALL handler keys across every state
  3. Exclude<..., SpecialStateKeys> — strips lifecycle/special keys