immerjs / use-immer

Use immer to drive state with a React hooks
MIT License
4.04k stars 92 forks source link

State type is not being properly propagated to draft object in updater produce function #130

Open cbdeveloper opened 4 months ago

cbdeveloper commented 4 months ago

Hey there,

I was trying to use the useImmer and pass the immer producer function, but it seems that the strict type is not being properly propagated to the draft argument object.

As we can see here, draft is being evaluated as Draft<S>, and accepts anything without throwing a type error.

image image

If I pass the object directly, it works fine:

image

Am I missing something?

Thank you

mweststrate commented 4 months ago

screenshot are not debuggable. please create a minimal repro in codesandbox.io or something similar.