Skip to content
Myr

Flow: add type for produceWithPatches

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

authored by rednaZ · committed by rednaZ · parent 6371d05 · Browse files · 1 file+24 added−0 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+24 added−0 removed

  • other:+24 added−0 removed

1 file+24 added−0 removed

modified:src/types/index.js.flow+24 added
37 unmodified lines
38 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void39 ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S;40}4142interface IProduceWithPatches {43 /**44 * Like `produce`, but instead of just returning the new state,45 * a tuple is returned with [nextState, patches, inversePatches]46 *47 * Like produce, this function supports currying48 */49 <S: Base>(50 currentState: S,51 recipe: (draftState: S) => S | void52 ): [S, Patch[], Patch[]];53 // curried invocations with inital state54 <S: Base, A = void, B = void, C = void>(55 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,56 initialState: S57 ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];58 // curried invocations without inital state59 <S: Base, A = void, B = void, C = void>(60 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void61 ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];62}6364declare export var produce: IProduce65declare export default IProduce6667declare export var produceWithPatches: IProduceWithPatches6869declare export var nothing: typeof undefined7071declare export var immerable: Symbol72
39 unmodified lines