immerjs / immer

Create the next immutable state by mutating the current one

Home Page:https://immerjs.github.io/immer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose a `Producer<T>` generic type

ianstormtaylor opened this issue Β· comments

πŸš€ Feature Proposal

Right now it's really hard to figure out how to properly type a producer function. It would be really nice if there was an easy Producer<T> to refer to the producer function for a Draft<T>.

For example to pass a producer function around in React's context.

Example

let ProducerContext = createContext<Producer<MyState> | null>(null)

Makes sense! PR welcome

@mweststrate I think there is a PR, although not sure the naming is quite right.

I saw there was an open PR for this but had a comment on it for rename and has since not been addressed can I just update that? what are the rules for this?

I've created one on draft at the moment #1004

This issue can probably be closed given that PR #968 has been merged