Type Alias Schema<D, P, _S, _T, _E, _C>

Schema<D, P, _S, _T, _E, _C>: {
    context?: _C;
    events?: [keyof _E] extends [never]
        ? {
            [NEVER]?: never;
        }
        : IsStringLiteral<keyof _E> extends false
            ? "Error: Event types must be literal strings."
            : {
                [T in keyof _E]: T extends ReservedKeyword
                    ? `Error: Event type '${T}' is reserved.`
                    : IsPlainObject<_E[T]> extends false
                        ? "Error: Event must be a plain object."
                        : "type" extends keyof _E[T]
                            ? "Error: Event cannot have a reserved property 'type'."
                            : _E[T]
            };
    strict?: IsBooleanLiteral<_T> extends false
        ? "Error: `strict` must be a `true` or `false`."
        : _T;
}

The type of schema for state machine.

Type Parameters

  • D

    The type of definition for state machine.

  • P extends ReadonlyArray<keyof any>

    The type of path from definition root to here.

  • _S = Get<D, P>

    (internal) The type of schema.

  • _T = Get<_S, ["strict"]>

    (internal) The type of strict property in schema.

  • _E = Get<_S, ["events"]>

    (internal) The type of events property in schema.

  • _C = Get<_S, ["context"]>

    (internal) The type of context property in schema.

Type declaration

  • Optional Readonlycontext?: _C

    The context of the state machine.

  • Optional Readonlyevents?: [keyof _E] extends [never]
        ? {
            [NEVER]?: never;
        }
        : IsStringLiteral<keyof _E> extends false
            ? "Error: Event types must be literal strings."
            : {
                [T in keyof _E]: T extends ReservedKeyword
                    ? `Error: Event type '${T}' is reserved.`
                    : IsPlainObject<_E[T]> extends false
                        ? "Error: Event must be a plain object."
                        : "type" extends keyof _E[T]
                            ? "Error: Event cannot have a reserved property 'type'."
                            : _E[T]
            }

    The event types that are allowed in the state machine.

  • Optional Readonlystrict?: IsBooleanLiteral<_T> extends false
        ? "Error: `strict` must be a `true` or `false`."
        : _T
    • true - Reports errors for contexts and events that are not defined in the schema.
    • false - Type inference is performed whenever possible.