Skip to content

Conversation

@ICodeMyOwnLife
Copy link
Contributor

@ICodeMyOwnLife ICodeMyOwnLife commented Jul 23, 2021

Hey maintainers,

As I can see, Promise<A> | Promise<B> is stricter than Promise<A | B> and to the point that it won't work with async functions.

Screen Shot 2021-07-23 at 21 11 48

In the case of onMutate, because we currently define its type as

onMutate?: (variables: TVariables) => Promise<TContext> | Promise<undefined> | TContext | undefined;

, when we set an async function to it we'll receive a type error but it's very obscure and appears at another place.

Screen Shot 2021-07-23 at 21 09 10

So in this PR, I set the return type of onMutate to Promise<TContext | undefined> instead of Promise<TContext> | Promise<undefined> to relax it to make it work with async functions.

set the return type of onMutate as Promise<TContext | undefined> instead of Promise<TContext> | Promise<undefined> to make it work with async functions
@vercel
Copy link

vercel bot commented Jul 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/Bur2c4i2WKX8wMgBdyVwU2jVbUoe
✅ Preview: https://react-query-git-fork-icodemyownlife-fix-on-864f4a-tannerlinsley.vercel.app

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 06a756f:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

@TkDodo TkDodo merged commit b95b865 into TanStack:master Jul 25, 2021
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.19.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants