Skip to content

Commit

Permalink
fix(ts): produce function
Browse files Browse the repository at this point in the history
Fixes #270
  • Loading branch information
aleclarson committed Dec 16, 2018
1 parent 025841e commit fa5bf5d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/immer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ export interface IProduce {
* @param {Function} patchListener - optional function that will be called with all the patches produced here
* @returns {any} a new state, or the initial state if nothing was modified
*/
<S = any, R = never>(
currentState: S,
recipe: (this: Draft<S>, draft: Draft<S>) => void | R,
<State, Result = any>(
currentState: State,
recipe: (this: Draft<State>, draft: Draft<State>) => Result,
listener?: PatchListener
): R
): void extends Result ? State : Result

/** Curried producer with an initial state */
<S = any, R = never>(
recipe: (this: Draft<S>, draft: Draft<S>) => void | R,
defaultBase: S
): (base: S | undefined) => R
<State, Result = any>(
recipe: (this: Draft<State>, draft: Draft<State>) => void | Result,
defaultBase: State
): (base: State | undefined) => void extends Result ? State : Result

/** Curried producer with no initial state */
<S = any, R = never, Args extends any[] = any[]>(
<State, Result = any, Args extends any[] = any[]>(
recipe: (
this: Draft<S>,
draft: Draft<S>,
this: Draft<State>,
draft: Draft<State>,
...extraArgs: Args
) => void | R
): (base: S, ...extraArgs: Args) => R
) => void | Result
): (base: State, ...extraArgs: Args) => void extends Result ? State : Result
}

export const produce: IProduce
Expand Down

0 comments on commit fa5bf5d

Please sign in to comment.