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

Unable to pass generic to produce for dynamic typing #1130

Open
yasinitskyi opened this issue Jun 19, 2024 · 0 comments
Open

Unable to pass generic to produce for dynamic typing #1130

yasinitskyi opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@yasinitskyi
Copy link

yasinitskyi commented Jun 19, 2024

🙋‍♂ Question

I am unable to pass generic parameter type to my produce function in order to propagate that generic to type of draft itself like so:
SearchContextProvider:
Screenshot 2024-06-19 at 10 59 49 PM
Reducer:
Screenshot 2024-06-19 at 11 00 43 PM
State for the draft to be applied:
Screenshot 2024-06-19 at 11 01 21 PM
Error:
Screenshot 2024-06-19 at 11 01 42 PM

This only occures with generic, if I use concrete type I won't get such error (namely If I replace generic with ResultDummy - error vanishes.

How do I go about it since this Provider supposed to be used in different part of the code and should receive different type depends on part of the code where it is used. Thank you!

Here is playground where I reproduced the issue:
https://codesandbox.io/s/produce-with-generic-vchkj4

Environment

We only accept questions against the latest Immer version.

  • Immer version: "^10.1.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant