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
Hi, I'm currently facing an issue with theinvoke section of a state.
For some reason, it is not possible to add any information in my current installed version"xstate": "^5.19.2", and"typescript": "^5.6.3",.
I always end up with the following Typescript issue.
TS2353: Object literal may only specify known properties, and src does not exist in type readonly never[]types.d.ts(285, 5): The expected type comes from property invoke which is declared here on typeIs it any unknown bug in the type definitions, or is it just the wrong place?
I needed to add a fake actor to use theinvoke statement for adding a callback inline.
see:
constmachine=setup({actors:{// FIXME: This is a workaround to make the `invoke` work and fix `never` type issues.fake:{}asany,},}).createMachine({//...states:{//...exampleState:{invoke:{src:fromCallback(({ sendBack, self, input, system})=>{//...}),},},},});
Expected result
constmachine=setup({//...}).createMachine({//...states:{//...exampleState:{invoke:{src:fromCallback(({ sendBack, self, input, system})=>{//...}),},},},});
Actual result
TS2353: Object literal may only specify known properties, and src does not exist in type readonly never[]types.d.ts(285, 5): The expected type comes from property invoke which is declared here on typeReproduction
https://stackblitz.com/edit/github-xtgithyn?file=src%2FfeedbackMachine.ts&view=editor
Additional context
"xstate": "^5.19.2",