Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): fix MutateFunction #674

Merged
merged 1 commit into from
Jun 30, 2020
Merged

Conversation

jelteliekens
Copy link
Contributor

TVariables now extends undefined to determine the return type of MutateFunction.

Fixes #661. When disableling --strictNullChecks undefined is always in every type's domain. undefined extends TVariables would always be true.

TVariables now extends undefined to determine the return type of MutateFunction.
@MichaelDeBoey MichaelDeBoey merged commit 0839ac8 into TanStack:master Jun 30, 2020
@MichaelDeBoey
Copy link
Collaborator

@all-contributors Please add @jelteliekens for code

@allcontributors
Copy link
Contributor

@MichaelDeBoey

I've put up a pull request to add @jelteliekens! 🎉

@basslagter
Copy link

As I said in my issue (#661), this fix doesn't seem to be helpfull

@jelteliekens
Copy link
Contributor Author

@basslagter It is merged with master but not yet release. v2.4.6 doesn't include this fix yet. Hopefully it does solve your issue once it get released.

@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 2.4.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@basslagter
Copy link

Works! Thanks

@justincy
Copy link
Contributor

I think that this change is making variables required when calling the mutate function, whereas previously you were able to call the mutate function without any arguments. Is that intended? The docs say arguments are optional.

@jelteliekens
Copy link
Contributor Author

Can you give a code example? If you expect variabels in the mutate function to do your API call, isn’t it required to pass variables when calling the mutation function?

@justincy
Copy link
Contributor

Yes, but not all API calls require variables and thus mutate doesn't require it either: https://github.com/tannerlinsley/react-query#returns-3

const [mutate] = useMutation(() => {
    return axiox.post('/some/url');
});

@justincy
Copy link
Contributor

justincy commented Jun 30, 2020

I don't know what the right fix is. I'm not claiming this needs to be reverted. But before this change I was able to call mutate with no args, then after the change the compiler is telling me that at least one arg is required. I deal with it by just passing undefined.

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.

useMutation expects incorrect mutateOptions as argument on mutate
5 participants