I'm using partial wildcard transitions as described in the docs here https://stately.ai/docs/transitions#partial-wildcard-transitions.
What is the recommended way to type events so that, inside actions for a wildcard transition, the event parameter is narrowed to only the matching events?
let's say I have an event like this
type FeedbackEvent =
| { type: 'FEEDBACK.*`; message: string }
Then I want type safety in my actions. I believe the inline case here works great without any assertEvent at all, but if I were to move it to a named action, I probably want some type narrowing.
on: {
'FEEDBACK.*': {
actions: [
({ event }) => {
// How can I get `event` narrowed to `{ type: `feedback.${string}`; message: string }` here?
console.log(event.message);
},
],
},
},
A transition is a change from one finite state to another, triggered by an event.