immer icon indicating copy to clipboard operation
immer copied to clipboard

Expose a `Producer<T>` generic type

Open ianstormtaylor opened this issue 2 years ago • 1 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 a 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)

ianstormtaylor avatar Jun 28 '22 18:06 ianstormtaylor

Makes sense! PR welcome

mweststrate avatar Jul 11 '22 19:07 mweststrate

Good idea! PR welcome :)

On Tue, Jun 28, 2022 at 7:33 PM Ian Storm Taylor @.***> wrote:

🚀 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 a the producer function for a Draft<T>.

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

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

— Reply to this email directly, view it on GitHub https://github.com/immerjs/immer/issues/955, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBDPQF2R6OBN43NJNKTVRNAPXANCNFSM52DD3CBA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mweststrate avatar Oct 11 '22 07:10 mweststrate

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

ianstormtaylor avatar Oct 12 '22 16:10 ianstormtaylor

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 https://github.com/immerjs/immer/pull/1004

NickSolante avatar Dec 31 '22 05:12 NickSolante

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

tlylt avatar Jan 27 '23 15:01 tlylt