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

Typescript version for zustand redux middleware with dispatch #212

Closed
Phibee opened this issue Oct 20, 2020 · 2 comments · Fixed by #601
Closed

Typescript version for zustand redux middleware with dispatch #212

Phibee opened this issue Oct 20, 2020 · 2 comments · Fixed by #601
Labels
enhancement New feature or request typescript This issue is about TypeScript

Comments

@Phibee
Copy link

Phibee commented Oct 20, 2020

Can you give example of your zustand and redux calling dispatch action like this link below using typescript? I believe there's a dispatch on zustand middleware don't know how to use it.

Codesandbox link

@dai-shi
Copy link
Member

dai-shi commented Oct 20, 2020

Good point. I don't think we support typing api.dispatch currently.
Here's my modification with some type assertions. (Not sure how to type curried produce.)
https://codesandbox.io/s/zustand-immer-redux-forked-q2nkn?file=/src/createStore.ts

We could technically improve store typing with better generics. It can be messy, and I wouldn't feel like doing now with my limited ts skills, unless someone volunteers for it.

@dai-shi
Copy link
Member

dai-shi commented Oct 21, 2021

I think I did it! 🎉
With #601, the type inference works:
https://codesandbox.io/s/zustand-immer-redux-forked-ozwr3?file=/src/createStore.ts

@dai-shi dai-shi removed the help wanted Please someone help on this label Oct 21, 2021
@dai-shi dai-shi linked a pull request Oct 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request typescript This issue is about TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants