mattpocock / xstate-codegen

A codegen tool for 100% TS type-safety in XState
MIT License
245 stars 12 forks source link

withConfig is not strongly typed #32

Closed mattpocock closed 3 years ago

mattpocock commented 4 years ago

machine.withConfig() is not strongly typed, meaning that it's very difficult to get nice typings when using interpret.

mwarger commented 4 years ago

Thanks, I have also run into this.

I have also tried using the spawn to pass a service to children as in this example: https://codesandbox.io/s/xstate-todomvc-33wr94qv1?from-embed=&file=/todoMachine.js

It seems like the service or machine is not necessarily typed, as the "sub-machine" matches function is not typed strongly. I'm not sure if this is related to what you're alluding to.

mattpocock commented 4 years ago

Yes, that's a good example of something that would be strongly typed if we fixed this.