Unable to pass generic to produce for dynamic typing
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 881
- PR merge metrics
- No merged PRs in 30d
Description
🙋♂ 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:
Reducer:
State for the draft to be applied:
Error:
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"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and compare the generic and concrete calls shown in the issue. Read Immer's TypeScript declarations for produce and its related draft types. Done means determining whether the reported generic call is supported or documenting the required usage, with a focused reproduction or test if a library change is needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100