-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: default to fetch type in keyed mutator #2753
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 |
---|---|---|
|
@@ -62,9 +62,11 @@ export function useMutatorTypes() { | |
|
||
mutate(async () => '1') | ||
|
||
// @ts-expect-error | ||
mutate(async () => 1) | ||
|
||
mutate(async () => 1, { populateCache: false }) | ||
// FIXME: this should work. | ||
// mutate(async () => 1, { populateCache: false }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @promer94 thanks for adding the test, maybe we should create an issue to follow up on this? it feels like a regression for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original pr #2708 did not fix this correctly so there is no regression here. I also think we should not support this because the type implementation would be really complicated and not useful in practice. You should always make sure you data has same structure as cache when using the bounded mutate fn. I just keep it here as a reference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right the type is number, I updated them in #2781 |
||
} | ||
|
||
export function useConfigMutate() { | ||
|
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.
@promer94 Why was this change reverted? It makes the generic completely useless and returning different
MutationData
to be passed topopulateCache
impossible with proper types.This probably needs to be overload based to function properly, otherwise
MutationData
will just be inferred improperly from the data arg, although it is mostly possible to do without overloads with some rather extensive types:I have tested the above and it works as expected, except in the case where
opts
is not passed or is aboolean
. This is why I suggested the overload approach, since if options is not passed as an object, typescript doesn't enforce it being passed.