Getting type error when using generics with mutationFn #5188
Unanswered
ThreeSeaGrass
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Edited link |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hm, I don't really understand the problem, but I've narrowed it down to an even simpler example. It has nothing to do with the conditional return type, but with the generic on the input: It works if we remove |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to generically type my API call so that I can reuse, however the mutation code (which was previously fine, before typing) is now kicking up an error:
No overload matches this call.
The last overload gave the following error.
Argument of type '{ mutationFn: ({ payload, method, }: { payload: any; method: T; }) => Promise<ResponseType | undefined>; }' is not assignable to parameter of type 'MutationKey'.
Object literal may only specify known properties, and 'mutationFn' does not exist in type 'readonly unknown[]'.
I've tried adding a mutation key before mutationFn but no luck. I've also seen that multiple params seem to produce this error however I believe I'm passing in an object.
Any help appreciated :)
Edit: clicking the link doesn't work but pasting does! (please ignore rependency error as should illustrate error)
I've created a simplified version of the code here: https://codesandbox.io/embed/typescript-playground-export-forked-yvmu69?fontsize=14&hidenavigation=1&theme=dark
Beta Was this translation helpful? Give feedback.
All reactions