You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created the following state machine. However, when I tried declaring a non-existant event eventThatDoesNotExist, no type error is generated. (Refer to code snippet)
import{setup,assign}from"xstate";exportconststateMachine=setup({types: {input: {}as{numTimesWalked: number;numTimesStanding?: number;},context: {}as{numTimesWalked: number;numTimesStanding?: number;},events: {}as|{type: "toggle"}|{type: "reset"}|{type: "turnOff"}|{type: "walk"}|{type: "stopWalking"}|{type: "startWalkingFromIdle"}|{type: "setNumTimesWalked";num: number}|{type: "setNumTimesStanding";num: number},},}).createMachine({id: "StateMachineWithUpdateContextInput",description: "Simple Test Machine",initial: "idle",context: ({ input })=>({numTimesWalked: input.numTimesWalked,}),// global eventson: {reset: {target: ".idle",actions: assign(()=>({numTimesStanding: 0,numTimesWalked: 0,})),},turnOff: {target: ".off"},},// state related eventsstates: {idle: {on: {toggle: "active",startWalkingFromIdle: "active.walking",setNumTimesWalked: {actions: assign(({event: { num }})=>({numTimesWalked: num,})),},},},active: {on: {toggle: "idle",},initial: "standing",states: {standing: {entry: assign(({ context })=>({numTimesStanding: (context.numTimesStanding||0)+1,})),on: {eventThatDoesNotExist: {actions: assign(({event: { num }})=>({numTimesStanding: num,})),},walk: "walking",},},walking: {entry: assign(({ context })=>({numTimesWalked: context.numTimesWalked+1,})),on: {stopWalking: "standing",},},},},off: {type: "final",description: "This is the final state. No transitions can happen from me",},},});
Expected result
Typescript error to be shown for "eventThatDoesNotExist" event type.
Actual result
Typescript error is not shown for "eventThatDoesNotExist" event type.
It wasnt until I changed 3 more events to something that does not exist, then the typescript error appears. Even then, the type error is only for 2 of the erronous events. (Refer to screenshot)
Reproduction
Can refer to the code snippet in the description
Additional context
No response
The text was updated successfully, but these errors were encountered:
XState version
XState version 5
Description
I created the following state machine. However, when I tried declaring a non-existant event eventThatDoesNotExist, no type error is generated. (Refer to code snippet)
Expected result
Typescript error to be shown for "eventThatDoesNotExist" event type.
Actual result
Typescript error is not shown for "eventThatDoesNotExist" event type.
It wasnt until I changed 3 more events to something that does not exist, then the typescript error appears. Even then, the type error is only for 2 of the erronous events. (Refer to screenshot)
Reproduction
Can refer to the code snippet in the description
Additional context
No response
The text was updated successfully, but these errors were encountered: