Skip to content
Myr

fix(ts): base type of curried producer

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

Previously, a curried producer could not be passed a readonly version of its expected base type. For example, a curried producer that expects its draft argument to be "any[]" could not be passed a "ReadonlyArray<any>" value. Related test: f94fcaaee9bb39c52c32c64cf59fbadf352fae05

authored by aleclarson · committed by aleclarson · parent f94fcaa · Browse files · 2 files+33 added−17 removed
This commit

State

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

Diff stats

2 files+33 added−17 removed

  • tests:+25 added−15 removed
  • other:+8 added−2 removed

2 files+33 added−17 removed

modified:__tests__/produce.ts+25 added-15 removed
modified:src/immer.d.ts+8 added-2 removed
94 unmodified lines
95 draft: Draft<Base>,96 ...rest: Rest97 ) => Return,98 defaultBase: Default99 ): (base: Base | undefined, ...rest: Rest) => Produced<Base, Return>99 ): <T>(100 base: (Draft<T> extends Draft<Base> ? T : Base) | undefined,101 ...rest: Rest102 ) => Produced<Base, Return>103104 /** Curried producer with no default value */105 <Base = any, Rest extends any[] = [], Return = void>(106 recipe: (this: Draft<Base>, draft: Draft<Base>, ...rest: Rest) => Return104 ): (base: Base, ...rest: Rest) => Produced<Base, Return>107 ): <T>(108 base: Draft<T> extends Draft<Base> ? T : Base,109 ...rest: Rest110 ) => Produced<Base, Return>111}112113export const produce: IProduce114export default produce
95 unmodified lines