diff --git a/src/types/index.js.flow b/src/types/index.js.flow index fb952be4..29758fbd 100644 --- a/src/types/index.js.flow +++ b/src/types/index.js.flow @@ -39,9 +39,33 @@ interface IProduce { ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S; } +interface IProduceWithPatches { + /** + * Like `produce`, but instead of just returning the new state, + * a tuple is returned with [nextState, patches, inversePatches] + * + * Like produce, this function supports currying + */ + ( + currentState: S, + recipe: (draftState: S) => S | void + ): [S, Patch[], Patch[]]; + // curried invocations with inital state + ( + recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void, + initialState: S + ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]]; + // curried invocations without inital state + ( + recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void + ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]]; +} + declare export var produce: IProduce declare export default IProduce +declare export var produceWithPatches: IProduceWithPatches + declare export var nothing: typeof undefined declare export var immerable: Symbol