-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix mutation hooks types #11024
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: next
Are you sure you want to change the base?
Fix mutation hooks types #11024
Changes from all commits
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -272,13 +272,10 @@ export interface UseDeleteMutateParams<RecordType extends RaRecord = any> { | |||||||||||||||||||||||
| export type UseDeleteOptions< | ||||||||||||||||||||||||
| RecordType extends RaRecord = any, | ||||||||||||||||||||||||
| MutationError = unknown, | ||||||||||||||||||||||||
| > = Omit< | ||||||||||||||||||||||||
| UseMutationOptions< | ||||||||||||||||||||||||
| RecordType, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseDeleteMutateParams<RecordType>> | ||||||||||||||||||||||||
| >, | ||||||||||||||||||||||||
| 'mutationFn' | ||||||||||||||||||||||||
| > = UseMutationOptions< | ||||||||||||||||||||||||
| RecordType, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseDeleteMutateParams<RecordType>> | ||||||||||||||||||||||||
|
Comment on lines
+275
to
+278
|
||||||||||||||||||||||||
| > = UseMutationOptions< | |
| RecordType, | |
| MutationError, | |
| Partial<UseDeleteMutateParams<RecordType>> | |
| > = Omit< | |
| UseMutationOptions< | |
| RecordType, | |
| MutationError, | |
| Partial<UseDeleteMutateParams<RecordType>> | |
| >, | |
| 'mutationFn' |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -298,13 +298,10 @@ export type UseDeleteManyOptions< | |||||||||||||||||||||||
| RecordType extends RaRecord = any, | ||||||||||||||||||||||||
| MutationError = unknown, | ||||||||||||||||||||||||
| TReturnPromise extends boolean = boolean, | ||||||||||||||||||||||||
| > = Omit< | ||||||||||||||||||||||||
| UseMutationOptions< | ||||||||||||||||||||||||
| Array<RecordType['id']> | undefined, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseDeleteManyMutateParams<RecordType>> | ||||||||||||||||||||||||
| >, | ||||||||||||||||||||||||
| 'mutationFn' | ||||||||||||||||||||||||
| > = UseMutationOptions< | ||||||||||||||||||||||||
| Array<RecordType['id']> | undefined, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseDeleteManyMutateParams<RecordType>> | ||||||||||||||||||||||||
|
Comment on lines
+301
to
+304
|
||||||||||||||||||||||||
| > = UseMutationOptions< | |
| Array<RecordType['id']> | undefined, | |
| MutationError, | |
| Partial<UseDeleteManyMutateParams<RecordType>> | |
| > = Omit< | |
| UseMutationOptions< | |
| Array<RecordType['id']> | undefined, | |
| MutationError, | |
| Partial<UseDeleteManyMutateParams<RecordType>> | |
| >, | |
| 'mutationFn' |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -305,13 +305,10 @@ export interface UseUpdateMutateParams<RecordType extends RaRecord = any> { | |||||||||||||||||||||||
| export type UseUpdateOptions< | ||||||||||||||||||||||||
| RecordType extends RaRecord = any, | ||||||||||||||||||||||||
| ErrorType = Error, | ||||||||||||||||||||||||
| > = Omit< | ||||||||||||||||||||||||
| UseMutationOptions< | ||||||||||||||||||||||||
| RecordType, | ||||||||||||||||||||||||
| ErrorType, | ||||||||||||||||||||||||
| Partial<UseUpdateMutateParams<RecordType>> | ||||||||||||||||||||||||
| >, | ||||||||||||||||||||||||
| 'mutationFn' | ||||||||||||||||||||||||
| > = UseMutationOptions< | ||||||||||||||||||||||||
| RecordType, | ||||||||||||||||||||||||
| ErrorType, | ||||||||||||||||||||||||
| Partial<UseUpdateMutateParams<RecordType>> | ||||||||||||||||||||||||
|
Comment on lines
+308
to
+311
|
||||||||||||||||||||||||
| > = UseMutationOptions< | |
| RecordType, | |
| ErrorType, | |
| Partial<UseUpdateMutateParams<RecordType>> | |
| > = Omit< | |
| UseMutationOptions< | |
| RecordType, | |
| ErrorType, | |
| Partial<UseUpdateMutateParams<RecordType>> | |
| >, | |
| 'mutationFn' |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -287,13 +287,10 @@ export interface UseUpdateManyMutateParams<RecordType extends RaRecord = any> { | |||||||||||||||||||||||
| export type UseUpdateManyOptions< | ||||||||||||||||||||||||
| RecordType extends RaRecord = any, | ||||||||||||||||||||||||
| MutationError = unknown, | ||||||||||||||||||||||||
| > = Omit< | ||||||||||||||||||||||||
| UseMutationOptions< | ||||||||||||||||||||||||
| Array<RecordType['id']>, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseUpdateManyMutateParams<RecordType>> | ||||||||||||||||||||||||
| >, | ||||||||||||||||||||||||
| 'mutationFn' | ||||||||||||||||||||||||
| > = UseMutationOptions< | ||||||||||||||||||||||||
| Array<RecordType['id']>, | ||||||||||||||||||||||||
| MutationError, | ||||||||||||||||||||||||
| Partial<UseUpdateManyMutateParams<RecordType>> | ||||||||||||||||||||||||
|
Comment on lines
+290
to
+293
|
||||||||||||||||||||||||
| > = UseMutationOptions< | |
| Array<RecordType['id']>, | |
| MutationError, | |
| Partial<UseUpdateManyMutateParams<RecordType>> | |
| > = Omit< | |
| UseMutationOptions< | |
| Array<RecordType['id']>, | |
| MutationError, | |
| Partial<UseUpdateManyMutateParams<RecordType>> | |
| >, | |
| 'mutationFn' |
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.
Allowing
mutationFnin the options type creates an inconsistent API. The type now acceptsmutationFn, but the runtime implementation (line 116) will silently override any user-provided value since it's defined after...mutationOptionsis spread (line 113). This mismatch between the type system and runtime behavior could confuse API consumers. Consider either: (1) keeping theOmit<..., 'mutationFn'>to prevent users from passing it, or (2) restructuring the code to respect a user-providedmutationFnif that's the intended behavior.