xstate
xstate copied to clipboard
Bug: Schema of context defined, yet not recognized in action
Description
Trying to follow along from an example here
The schema is defined in the context but it's not detected in TypeScript and the context property is shown as undefined

Here is a minimal reproduction: https://codesandbox.io/s/currying-wind-4ohyf8?file=/src/index.ts
Expected result
No type errors
Actual result
Getting type errors
Reproduction
https://codesandbox.io/s/currying-wind-4ohyf8?file=/src/index.ts
Additional context
XState version: 4.32.0
I think the problem here might be related to a certain circularity in the assign's type definition that makes it hard for TS to infer this.
As a workaround you can type context parameter explicitly, like here. It's not ideal but fixing this in XState might take some time.
But wouldn't this also disable the typegen tooling completely? That's more harm done, no?
Closing as the sandbox could not be found and may no longer be reproducible with the latest XState version.
If you can share a reproducible sandbox with the latest XState version, will reopen.