statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.18k stars 1.26k forks source link

Bug: [Typescript] `enqueueActions` throws a type error when declared within setup actions #4923

Open andrecrimb opened 5 months ago

andrecrimb commented 5 months ago

XState version

XState version 5

Description

TS throws an error when enqueuedActions is declared within setups > actions.

Expected result

No type error should be raised.

Actual result

Screenshot 2024-05-31 at 11 02 37

Reproduction

Sandbox link

Additional context

xstate: 5.13.0 typescript: "5.3.3

davidkpiano commented 5 months ago

Which TypeScript version are you using?

Regardless this may be a TS limitation (cc. @Andarist)

andrecrimb commented 5 months ago

Sorry, I forgot to add it into the description.
"typescript": "5.3.3"

bsunderhus commented 2 months ago

Bumped into the same issue: https://stackblitz.com/edit/vitejs-vite-rggwb5?file=src%2Fmain.ts

Seems like the TActions generic is resolving to never on enqueue declaration

image

xstate: "5.18.1" typescript: "5.5.4"