In the machine in the example (parts removed for simplicity), in the definition of updateRecentSongs, "event" is inferred as { type: 'init' } | { type: 'play' }. The event however in this case comes from a promise actor and would have an output field with type Song[]. How can I make that available in the action (for narrowing)? Would adding an event of type done.invoke.app.loading:invocation[0] to the schema be the best way?
#Typing actions's event parameter in v5
1 messages · Page 1 of 1 (latest)
Wow I have exactly the same question!
On a similar topic I was wondering if in v5 is best to use the onDone and onError with invoke with a promise ( to fetch data ), or if the callback with explicit separate states and events is still "slighlty more" recommended and easier to strongly type.
same Question
ok, when the action is inline works fine,
actions: [ ({event}) => console.log(event.output), {
the output in that case is typed correctly.
not sure if this is the right approach but I defined the action like this in order to have it strongly typed
When you say inline, did you also write your invoke function inline to get it working?
I have errors in the machine about incompatibility of event types
Done events are something we still have to add to the types