Skip to content

Commit

Permalink
fix(ts): inline producer with generic type
Browse files Browse the repository at this point in the history
Fixes #272
  • Loading branch information
aleclarson committed Dec 18, 2018
1 parent 8ce6fd4 commit c5278a5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/immer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,22 @@ 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
*/
<Base, Result = any>(
<Base, Proxy = Draft<Base>, Result = any>(
base: Base,
recipe: (this: Draft<Base>, draft: Draft<Base>) => Result,
recipe: (this: Proxy, draft: Proxy) => Result,
listener?: PatchListener
): void extends Result ? Base : Result

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

/** Curried producer with no initial state */
<Base, Result = any, Args extends any[] = any[]>(
recipe: (
this: Draft<Base>,
draft: Draft<Base>,
...extraArgs: Args
) => Result
): (base: Base, ...extraArgs: Args) => void extends Result ? Base : Result
<Base, Rest extends any[] = any[], Result = any>(
recipe: (this: Draft<Base>, draft: Draft<Base>, ...rest: Rest) => Result
): (base: Base, ...rest: Rest) => void extends Result ? Base : Result
}

export const produce: IProduce
Expand Down

0 comments on commit c5278a5

Please sign in to comment.