From 05157afa75ee708327187cbac1b067bd259dc852 Mon Sep 17 00:00:00 2001 From: aleclarson Date: Sat, 12 Jan 2019 17:57:02 -0500 Subject: [PATCH] fix(ts): reorder generic parameters of IProduce This makes the different call signatures of `produce` have a similar order of generic parameters when possible. Before: produce((draft, num, str) => {}) // no default produce, [number, string]>((draft, num, str) => {}, defaultValue) After: produce((draft, num, str) => {}) // no default produce((draft, num, str) => {}, defaultValue) As you can see, the draft type is no longer the 2nd generic parameter of curried producers with a default value, which is just like the call signature for curried producers without a default value. This also moves the `D` generic parameter of `produce(base, recipe)` to the end, so you can specify the `Return` parameter easier. --- src/immer.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/immer.d.ts b/src/immer.d.ts index e58d6da6..e3b46555 100644 --- a/src/immer.d.ts +++ b/src/immer.d.ts @@ -97,14 +97,14 @@ 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 */ - , Return = void>( + >( base: T, recipe: (this: D, draft: D) => Return, listener?: PatchListener ): Produced /** Curried producer with a default value */ - , Rest extends any[] = [], Return = void>( + >( recipe: (this: D, draft: D, ...rest: Rest) => Return, defaultBase: T ): (base: Immutable | undefined, ...rest: Rest) => Produced