immer
immer copied to clipboard
Typings of `current()` don't reflect that returned object is not a draft
🐛 Bug Report
The typings of current() state that the input and return types are the same. This doesn't reflect that the function unwraps drafts.
Link to repro
const draft = immer.createDraft({ a: true });
immer.current(draft);
To Reproduce
Observe typings of the returned object. Runtime object is not a draft, but typings indicate that it is.
Observed behavior
Return type is the same as the input type.
export declare function current<T>(value: T): T;
Expected behavior
Return type is the type of thing whose draft was input.
export declare function current<T>(value: Draft<T>): T;
Environment
We only accept bug reports against the latest Immer version.
- Immer version: 9.0.12
- [x] I filed this report against the latest version of Immer
- [x] Occurs with
setUseProxies(true) - [x] Occurs with
setUseProxies(false)(ES5 only)
Same issue with original()
Feel free to submit a PR!
On Mon, 17 Jan 2022, 13:00 Robat Williams, @.***> wrote:
Same issue with original()
— Reply to this email directly, view it on GitHub https://github.com/immerjs/immer/issues/896#issuecomment-1014503533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBGUD3ORQRIPJVQTQETUWQHIXANCNFSM5METKFJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>