mattpocock / xstate-codegen

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

withConfig not typed correctly and withContext method missing from generated machine types #92

Open bahalperin opened 3 years ago

bahalperin commented 3 years ago

In xstate, withConfig is typed with context as a second, optional parameter. In xstate-codegen, the generated signature for withConfig lets you pass in context in the same object as the rest of the machine options. This ends up getting silently ignored and leads to confusing behavior.

The generated machines are also missing the withContext method. Typescript uses the original xstate method, which results in a type error because it returns the StateMachine type from xstate and not the generated machine type from xstate-codegen.