You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: Curried TS definition allows undefined to be passed as base
Version: 1.10.0
Expected behavior: produce currying definition which returns a function that takes a first argument of type Base (the way it used to work before 8666d32)
Observed behavior: produce currying definition that returns a function that takes Base | undefined as first parameter
The definition for the curried produce function used to be:
/** Curried producer with no initial state */
<State, Result = any, Args extends any[] = any[]>(
recipe: (
this: Draft<State>,
draft: Draft<State>,
...extraArgs: Args
) => void | Result
): (base: State, ...extraArgs: Args) => void extends Result ? State : Result
There are two different types of currying, I see now. Only one of the two should allow the first argument to be undefined. The more complex one with a defaultBase should still take Base | undefined, I think, but not the simpler one that I'm using?
The definition for the curried produce function used to be:
It is now:
The fact that the base can be undefined in the returned function messes up existing typescript code that doesn't expect this.
The text was updated successfully, but these errors were encountered: