Skip to content
Myr

fix(ts): use base type as default produce() return type

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Previously, the draft type was used in anticipation of weird edge cases, but this created a larger problem where `produce()` would return a fully mutable version of the base type.

authored by aleclarson · committed by aleclarson · parent b52b45e · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:src/immer.d.ts+1 added-1 removed
92 unmodified lines
93 <T = any, Return = void, D = Draft<T>>(94 base: T,95 recipe: (this: D, draft: D) => Return,96 listener?: PatchListener97 ): Produced<D, Return>97 ): Produced<T, Return>9899 /** Curried producer with a default value */100 <T = any, Rest extends any[] = [], Return = void, D = Draft<T>>(101 recipe: (this: D, draft: D, ...rest: Rest) => Return,
106 unmodified lines