Skip to content

Unable to pass generic to produce for dynamic typing #1130

Open
@yasinitskyi

Description

@yasinitskyi

🙋‍♂ 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"

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions