@@ -56,10 +56,10 @@ type IsVoidLike<T> =
56
56
type FromNothing < T > = Nothing extends T ? Exclude < T , Nothing > | undefined : T
57
57
58
58
/** The inferred return type of `produce` */
59
- type Produced < Base , Return > = 1 extends HasVoidLike < Return >
59
+ type Produced < T , Return > = 1 extends HasVoidLike < Return >
60
60
? 1 extends IsVoidLike < Return >
61
- ? Immutable < Base >
62
- : Immutable < Base > | FromNothing < Exclude < Return , void > >
61
+ ? Immutable < T >
62
+ : Immutable < T > | FromNothing < Exclude < Return , void > >
63
63
: FromNothing < Return >
64
64
65
65
type ImmutableTuple < T extends ReadonlyArray < any > > = {
@@ -97,32 +97,22 @@ export interface IProduce {
97
97
* @param {Function } patchListener - optional function that will be called with all the patches produced here
98
98
* @returns {any } a new state, or the initial state if nothing was modified
99
99
*/
100
- < Base , Proxy = Draft < Base > , Return = void > (
101
- base : Base ,
102
- recipe : ( this : Proxy , draft : Proxy ) => Return ,
100
+ < T = any , D = Draft < T > , Return = void > (
101
+ base : T ,
102
+ recipe : ( this : D , draft : D ) => Return ,
103
103
listener ?: PatchListener
104
- ) : Produced < Base , Return >
104
+ ) : Produced < D , Return >
105
105
106
106
/** Curried producer with a default value */
107
- < Default = any , Base = Default , Rest extends any [ ] = [ ] , Return = void > (
108
- recipe : (
109
- this : Draft < Base > ,
110
- draft : Draft < Base > ,
111
- ...rest : Rest
112
- ) => Return ,
113
- defaultBase : Default
114
- ) : < T > (
115
- base : ( Draft < T > extends Draft < Base > ? T : Base ) | undefined ,
116
- ...rest : Rest
117
- ) => Produced < Base , Return >
107
+ < T = any , D = Draft < T > , Rest extends any [ ] = [ ] , Return = void > (
108
+ recipe : ( this : D , draft : D , ...rest : Rest ) => Return ,
109
+ defaultBase : T
110
+ ) : ( base : Immutable < D > | undefined , ...rest : Rest ) => Produced < D , Return >
118
111
119
112
/** Curried producer with no default value */
120
- < Base = any , Rest extends any [ ] = [ ] , Return = void > (
121
- recipe : ( this : Draft < Base > , draft : Draft < Base > , ...rest : Rest ) => Return
122
- ) : < T > (
123
- base : Draft < T > extends Draft < Base > ? T : Base ,
124
- ...rest : Rest
125
- ) => Produced < Base , Return >
113
+ < T = any , Rest extends any [ ] = [ ] , Return = void > (
114
+ recipe : ( this : Draft < T > , draft : Draft < T > , ...rest : Rest ) => Return
115
+ ) : ( base : Immutable < T > , ...rest : Rest ) => Produced < T , Return >
126
116
}
127
117
128
118
export const produce : IProduce
0 commit comments