-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
in TypeScript, the mutation function created by the useMutation hook can always be called without passing arguments, because the type TVariables is set to optional:
To Reproduce
I made a codeSandbox example: https://codesandbox.io/s/async-currying-wepni
Please look at the comment at line 54
I should be forced to call that function like this:
mutatePostTodo(text)
but I can also call it like this:
mutatePostTodo()
Expected behavior
The type of variables that you need to pass to that function should be equal to the type that the actual mutation function accepts, in other words, it should be variables: TVariables rather than variables?: TVariables
Desktop (please complete the following information):
- OS: MacOS Catalina
- Browser: Chrome
- Version: 85
Additional context
All the usages of variables in that function are accessed with the bang operator, for example:
So I don't really see why it should be optional to begin with 🤷 .
Happy to make a PR if you approve of this :)