StateMatchboxFactory
StateMatchboxFactory<
Specs
> ={ [T in string & keyof Specs]: CreateState<Specs, T> }
Defined in: state-types.ts:48
Utility type for
- extracting the returned state types from a keyed state factory.
- extracting the returned payloads from DataSpecs
This is a type-level helper for state machine construction: given a tagged type spec (mapping state keys to factory functions or values),
States<Specs>
produces an object type where each key maps to its corresponding state creator function.
Use this to generate a set of state constructors for a state machine, ensuring type safety and consistency.
Example:
type MySpecs = { Idle: () => { ready: boolean }; Active: (user: string) => { user: string };};
type MyStates = StateMatchboxFactory<MySpecs>;// MyStates = {// Idle: () => StateMatchbox<'Idle', MySpecs>;// Active: (user: string) => StateMatchbox<'Active', MySpecs>;// }
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
Specs extends TaggedTypes |