-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(query-core): make MutateFunction optional undefinable-variables
#8737
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
2ddfb1c
3085870
02db0f2
01b77b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||
| import { describe, expectTypeOf, it } from 'vitest' | ||||||||||||||||||
| import type { MutateFunction } from 'src/types' | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('MutateFunction', () => { | ||||||||||||||||||
| it('optional undefinable variables', () => { | ||||||||||||||||||
| const mutate = {} as MutateFunction< | ||||||||||||||||||
| unknown, | ||||||||||||||||||
| unknown, | ||||||||||||||||||
| number | undefined, | ||||||||||||||||||
| unknown | ||||||||||||||||||
| > | ||||||||||||||||||
|
|
||||||||||||||||||
| expectTypeOf<Parameters<typeof mutate>[0]>().toEqualTypeOf< | ||||||||||||||||||
| number | undefined | ||||||||||||||||||
| >() | ||||||||||||||||||
|
|
||||||||||||||||||
| mutate() // can be called with no arguments | ||||||||||||||||||
|
||||||||||||||||||
| export type UseMutateFunction< | |
| TData = unknown, | |
| TError = DefaultError, | |
| TVariables = void, | |
| TContext = unknown, | |
| > = ( | |
| ...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>> | |
| ) => void |
would be great to have a test in useMutation.test-d.tsx in the react-query adapter for this then 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already covered this case. Please check my tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already covered this case
yeah that’s okay for the query-core, but it doesn’t actually test what useMutation in react-query does. It’s great that we cover the functionality that we have in useMutation now, but if we refactor that, it won’t be covered by the test in the core.
That’s why each adapter should have its own tests for the types they are doing. But we can do this in a follow-up.
Uh oh!
There was an error while loading. Please reload this page.