-
-
Notifications
You must be signed in to change notification settings - Fork 633
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: atomWithMachine typescript error after updating xstate to version 4.29.0 #1000
Comments
Thanks for reporting! Do you know how to fix it?? |
This is probably on our end; will take a look. |
still have the same problem even after updating to xstate 4.30.1 |
@violabg Can you make a reproducible example in CodeSandbox? |
here you go https://codesandbox.io/s/dreamy-dust-b33z7g on line 34 you can see the typescript error |
Any solution to resolve typescript miss match? |
@Andarist Do you know if this is already an issue on jotai end? |
@dai-shi thanks for the ping. Coincidentally I've figured out a fix for this just today, some more info can be found here. I will move forward with this to fix this and similar issues. Note that this doesn't fully fix the given repro case - the repro showcases 2 problems while the fix I'm talking about only fixes the first one. I think that I also know how to fix the second one though and gonna play around with this too. |
Actually... I might have read this wrong yesterday. I've released the fix for the mentioned issue and I fix it solves the problem in full here, the updated codesandbox is here: https://codesandbox.io/s/billowing-lake-wf3ixp?file=/src/App.tsx |
sorry to bother you again, but I'm still getting typescript errors, I have updated the CodeSandbox to reflect my real use case, you can find it here, maybe it's me doing something wrong, but I can't figure it out. https://codesandbox.io/s/awesome-drake-26p92f?file=/src/App.tsx |
@Andarist It seems that the typegen generic is incompatible with places where some of the generics are already specified: https://github.com/pmndrs/jotai/blob/main/src/xstate/atomWithMachine.ts#L14-L28 |
Yes, when the machine already contains the typegen stuff then consuming function is supposed to handle/forward it OR specify that it wants to ignore with I didn't figure out a way for this to work around as I could try to prepare changes to |
I'm new to Jotai and trying to use with my state machine. Any possible workarounds on this? Maybe I could somehow assert the correct type using some generic exported from Jotai? edit: I ended up just doing this as a workaround:
|
guys please fix it! refer to string types like |
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Bug: atomWithMachine typescript error after updating xstate to version 4.29.0
Description
I have updated xstate to version 4.29.0, and I'm getting a typescript error when adding a machine to atomWithMachine.
Expected result
no typescript error
Actual result
Reproduction
update to version 4.29.0, and add a machine to atomWithMachine
The text was updated successfully, but these errors were encountered: