Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: invoke id callback not typed as a function #4605

Open
j-5-s opened this issue Dec 18, 2023 · 3 comments · May be fixed by #4606
Open

Bug: invoke id callback not typed as a function #4605

j-5-s opened this issue Dec 18, 2023 · 3 comments · May be fixed by #4606

Comments

@j-5-s
Copy link

j-5-s commented Dec 18, 2023

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 j-5-s added the bug label Dec 18, 2023
@Andarist
Copy link
Member

Andarist commented Dec 18, 2023

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 Andarist linked a pull request Dec 18, 2023 that will close this issue
1 task
@j-5-s
Copy link
Author

j-5-s commented Dec 18, 2023

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

@Andarist
Copy link
Member

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants