xstate icon indicating copy to clipboard operation
xstate copied to clipboard

Bug: invoke id callback not typed as a function

Open j-5-s opened this issue 2 years ago • 3 comments

XState version

XState version 5

Description

The id can be used as a callback but I am getting typescript errors. Wondering its a bug in the typing or is this a bug in that it shouldnt take a callback? Screen Shot 2023-12-17 at 10 32 26 PM

Expected result

i expect only a string to work because thats what the typing is.

Actual result

A callback is what i need but the ts support isnt correct and shows an error.

Reproduction

https://codesandbox.io/p/devbox/dreamy-hill-ht77kt?file=%2Fsrc%2FfeedbackMachine.ts%3A44%2C9

Additional context

No response

j-5-s avatar Dec 18 '23 03:12 j-5-s

v4 didn't allow dynamic IDs on invoke but I don't see a reason why we shouldn't allow this in v5. spawnChild already supports this and both use the same implementation under the hood.

Andarist avatar Dec 18 '23 08:12 Andarist

Awesome, thank you. Dynamic id's are just what I needed!

j-5-s avatar Dec 18 '23 11:12 j-5-s

This turned out to be slightly more complicated than I anticipated since we were relying on those particular IDs to be static. This bit of the implementation is funky - so perhaps this will force us to rethink what we are doing there in terms of how we allow for entry sendTo actions targeting invoked actors to be "retried".

Andarist avatar Dec 20 '23 10:12 Andarist