Proper types for custom query hook
Hello. I'm trying to add types to custom query hook but get an error. What do I do wrong?
Here is the code:
Here is the error:
7 Replies
ratty-blush•3y ago
useful-bronzeOP•3y ago
I guess the main question is quite similar. I'm trying to make reusable wrapper hook. The main reason is to assign type correctly for resp and error. Do you think I need to get rid of this wrapper? Why?
ratty-blush•3y ago
then you need to get the generics right - all 4 of them 🙂
useful-bronzeOP•3y ago
I guess I've added three of them. Should I add generic for key? Is it a reason of error?
ratty-blush•3y ago
yes
useful-bronzeOP•3y ago
I've added forth type for query and the error still present:
ratty-blush•3y ago
show a typescript playground please