Closed MarkBennett closed 2 years ago
There is already StateValueFrom
type helper that you might use - however, it probably won't help you with making sure that you have covered all the cases. It sort of works but I'm worried that it might be a little bit problematic when it comes to covering parallel states and stuff.
I didn't play with it enough to be sure though. It would be best to just play with a type actually generated by the typegen to see how the narrowing works with what we produce there.
Thanks @Andarist. I'll take a look at StateValueFrom
as you suggest and see if that works. I've not worked too much with the never
type before so this is a chance to try that out!
I'm writing a React component and want to make sure that I'm covering all possible machine states in the UX. To do this, I'm exporting the
matchStates
type from the typegen in the same file where I define my machine.This seems tightly coupled to the typegen implementation though, so I'd be curious if there's a safer or more reliable way to export this, or to ensure a client library is handling all possible values of
state.value
? Would you be open to a PR exposing this, and if so any preferences on how?