immerjs / use-immer

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

Returning `nothing` in updater fails typescript compilation #63

Closed aeons closed 3 years ago

aeons commented 4 years ago

Per https://immerjs.github.io/immer/docs/return#producing-undefined-using-nothing, you can return the constant nothing to set a draft to undefined.

This fails when using useImmer, with Type 'Nothing' is not assignable to type 'void | T | undefined'.

I suspect the machinery for nothing is just missing from the types in this repo.

mweststrate commented 3 years ago

Fixed in 0.5.1