Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.3k
Open
Labels
Description
XState version
XState version 5
Description
I'd expect to get TS errors for this code:
constfeedbackMachine=setup({types:{context:{}as{feedback:string},events:{}as{type:"feedback.good"}|{type:"feedback.bad"},},}).createMachine({context:{feedback:"",},initial:"NON_EXISTING_STATE",// <---- i'd expect a TS error herestates:{idle:{on:{"feedback.good":{target:"NON_EXISTING_STATE",// <---- i'd expect a TS error here},},},},});
Expected result
I should only be allowed to pass valid state values (in my example onlyidle) to theinitial andtarget fields
Actual result
I'm allowed to pass a non existing state value to theinitial andtarget fields, which then yields runtime errors
Reproduction
https://codesandbox.io/p/devbox/great-leavitt-fw32ld?file=%2Fsrc%2FfeedbackMachine.ts%3A10%2C69
Additional context
No response