New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
The return type of the produce method will have an additional undefined #1003
Labels
Comments
remove the default assignment and it will work. |
type InferCurriedFromRecipe<
Recipe,
UsePatches extends boolean
> = Recipe extends (draft: infer DraftState, ...args: infer RestArgs) => any // verify return type
? ReturnType<Recipe> extends ValidRecipeReturnTypePossiblyPromise<DraftState>
? (
base: Immutable<DraftState>,
...args: RestArgs
) => PromisifyReturnIfNeeded<DraftState, Recipe, UsePatches> // N.b. we return mutable draftstate, in case the recipe's first arg isn't read only, and that isn't expected as output either
: never // incorrect return type
: never // not a function
|
@mweststrate maybe produce function should explicitly return draft to avoid this situation? |
recipes should not use a default argument, as they are never seen by |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
馃檵鈥嶁檪 Question
A clear and concise description of what the question is. In general we recommend to use Stack Overflow for questions. Questions typically are processed with less priority.
In the above code, I expect the type of the func to be
Record<string, string>
, but the actual type check returnsRecord<string, string> | undefined
, how can I avoid the undefined?This problem only occurs in 9.x versions
Link to repro
https://codesandbox.io/s/immer-sandbox-forked-n1okz2?file=/src/index.ts
Environment
We only accept questions against the latest Immer version.
setUseProxies(true)
setUseProxies(false)
(ES5 only)The text was updated successfully, but these errors were encountered: