Skip to content
Myr

fix: Better applyPatches type (#810)

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

applyPatches should specify its input as type `T` so that TypeScript can better infer the correct `T` for its output. Fixes #809

authored by Josh Kelley · committed by GitHub · parent b1fac9d · 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/core/immerClass.ts+1 added-1 removed
183 unmodified lines
184 }185 this.useProxies_ = value186 }187188 applyPatches<T extends Objectish>(base: Objectish, patches: Patch[]): T {188 applyPatches<T extends Objectish>(base: T, patches: Patch[]): T {189 // If a patch replaces the entire state, take that replacement as base190 // before applying patches191 let i: number192 for (i = patches.length - 1; i >= 0; i--) {
37 unmodified lines