Type Alias Shape<D, G, E, _S>

Shape<D, G, E, _S>: {
    $schema?: Schema<D, ["$schema"]>;
    initial: IsPlainObject<_S> extends false
        ? "Error: States must be a plain object."
        : [keyof _S] extends [never]
            ? "Error: No states defined."
            : IsStringLiteral<keyof _S> extends false
                ? "Error: States have no literal string value."
                : keyof _S;
    on?: On<D, ["on"], G>;
    states: IsPlainObject<_S> extends false
        ? "Error: States must be a plain object."
        : [keyof _S] extends [never]
            ? {
                [NEVER]?: never;
            }
            : IsStringLiteral<keyof _S> extends false
                ? "Error: State values must be literal strings."
                : {
                    readonly [V in keyof _S]: V extends ReservedKeyword
                        ? `Error: State value '${V}' is reserved.`
                        : Definition.State<D, ["states", V], G, E>
                };
} & ("context" extends keyof Get<D, ["$schema"]>
    ? {
        context: Context<D>;
    }
    : {
        context?: Context<D>;
    })

The type of state machine definition.

Type Parameters

  • D

    The type of definition for state machine.

  • G extends string

    The type of guards for state machine functions.

  • E extends string

    The type of effects for state machine functions.

  • _S = Get<D, ["states"]>

    (internal) The type of states.

Type declaration

  • Optional Readonly$schema?: Schema<D, ["$schema"]>
  • Readonlyinitial: IsPlainObject<_S> extends false
        ? "Error: States must be a plain object."
        : [keyof _S] extends [never]
            ? "Error: No states defined."
            : IsStringLiteral<keyof _S> extends false
                ? "Error: States have no literal string value."
                : keyof _S

    The initial state value.

  • Optional Readonlyon?: On<D, ["on"], G>

    The definition how a state machine will transition when it receives a specific event.

  • Readonlystates: IsPlainObject<_S> extends false
        ? "Error: States must be a plain object."
        : [keyof _S] extends [never]
            ? {
                [NEVER]?: never;
            }
            : IsStringLiteral<keyof _S> extends false
                ? "Error: State values must be literal strings."
                : {
                    readonly [V in keyof _S]: V extends ReservedKeyword
                        ? `Error: State value '${V}' is reserved.`
                        : Definition.State<D, ["states", V], G, E>
                }

    The state definitions.