Skip to content

fix(types): fix MutateFunction#674

Merged
MichaelDeBoey merged 1 commit into
TanStack:masterfrom
jelteliekens:master
Jun 30, 2020
Merged

fix(types): fix MutateFunction#674
MichaelDeBoey merged 1 commit into
TanStack:masterfrom
jelteliekens:master

Conversation

@jelteliekens

Copy link
Copy Markdown
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
Copy Markdown
Contributor

@all-contributors Please add @jelteliekens for code

@allcontributors

Copy link
Copy Markdown
Contributor

@MichaelDeBoey

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

@basslagter

Copy link
Copy Markdown

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

@jelteliekens

Copy link
Copy Markdown
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
Copy Markdown
Member

🎉 This PR is included in version 2.4.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@basslagter

Copy link
Copy Markdown

Works! Thanks

@justincy

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

justincy commented Jun 30, 2020

Copy link
Copy Markdown
Contributor

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.

@nx-cloud

nx-cloud Bot commented May 23, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3165838

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 57s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-29 02:06:41 UTC

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