create Machine < D > ( definition ) : Machine < D > Type Parameters D extends { $schema ?: Schema < D , [ "$schema" ] , "$schema" extends keyof D ? D [ keyof D & "$schema" ] extends undefined ? undefined : D [ keyof D & "$schema" ] : undefined , "strict" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "strict" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "strict" ] : undefined , "events" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "events" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "events" ] : undefined , "context" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "context" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "context" ] : undefined > ; initial : IsPlainObject < "states" extends keyof D ? D [ keyof D & "states" ] extends undefined ? undefined : D [ keyof D & "states" ] : undefined > extends false ? "Error: States must be a plain object." : [ keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ] extends [ never ] ? "Error: No states defined." : IsStringLiteral < keyof ( "states" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) > extends false ? "Error: States have no literal string value." : keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ; on ?: On < D , [ "on" ] , never > ; states : IsPlainObject < "states" extends keyof D ? D [ keyof D & "states" ] extends undefined ? undefined : D [ keyof D & "states" ] : undefined > extends false ? "Error: States must be a plain object." : [ keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ] extends [ never ] ? { [NEVER] ?: undefined ; } : IsStringLiteral < keyof ( "states" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) > extends false ? "Error: State values must be literal strings." : { readonly [ V in string | number | symbol ] : V extends ReservedKeyword ? ` Error: State value ' ${ V < V > } ' is reserved. ` : Definition . State < D , [ "states" , V ] , never , never > } ; } & ( { context : Context < D > ; } | { context ?: Context < D > ; } ) The state machine.
create Machine < D , const G , const E > ( definition , config ) : Machine < D > Type Parameters D extends { $schema ?: Schema < D , [ "$schema" ] , "$schema" extends keyof D ? D [ keyof D & "$schema" ] extends undefined ? undefined : D [ keyof D & "$schema" ] : undefined , "strict" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "strict" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "strict" ] : undefined , "events" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "events" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "events" ] : undefined , "context" extends keyof ( "$schema" extends keyof D ? D [ keyof ( ...) & "$schema" ] extends undefined ? undefined : D [ keyof ( ...) & "$schema" ] : undefined ) ? ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "context" ] extends undefined ? undefined : ( "$schema" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) [ keyof ( "$schema" extends keyof ( ...) ? ( ...) extends ( ...) ? ( ...) : ( ...) : undefined ) & "context" ] : undefined > ; initial : IsPlainObject < "states" extends keyof D ? D [ keyof D & "states" ] extends undefined ? undefined : D [ keyof D & "states" ] : undefined > extends false ? "Error: States must be a plain object." : [ keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ] extends [ never ] ? "Error: No states defined." : IsStringLiteral < keyof ( "states" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) > extends false ? "Error: States have no literal string value." : keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ; on ?: On < D , [ "on" ] , G > ; states : IsPlainObject < "states" extends keyof D ? D [ keyof D & "states" ] extends undefined ? undefined : D [ keyof D & "states" ] : undefined > extends false ? "Error: States must be a plain object." : [ keyof ( "states" extends keyof D ? D [ keyof ( ...) & "states" ] extends undefined ? undefined : D [ keyof ( ...) & "states" ] : undefined ) ] extends [ never ] ? { [NEVER] ?: undefined ; } : IsStringLiteral < keyof ( "states" extends keyof D ? D [ ( ...) & ( ...) ] extends undefined ? undefined : D [ ( ...) & ( ...) ] : undefined ) > extends false ? "Error: State values must be literal strings." : { readonly [ V in string | number | symbol ] : V extends ReservedKeyword ? ` Error: State value ' ${ V < V > } ' is reserved. ` : Definition . State < D , [ "states" , V ] , G , E > } ; } & ( { context : Context < D > ; } | { context ?: Context < D > ; } ) const G extends string = never const E extends string = never The state machine.
Create a state machine.
This function is used in conjunction with
useMachine
anduseSyncedMachine
. It cannot be used withuseSharedMachine
. In that case, usecreateSharedMachine
instead.