QueryClient DefaultOptions error type #2757
-
Hi, I am wondering why it is not possible to define the error type of the I am using it in this way:
Would |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
the safer way would be to let typescript perform type narrowing by doing runtime checks:
I've also written about that here: https://tkdodo.eu/blog/react-query-and-type-script#what-about-error |
Beta Was this translation helpful? Give feedback.
error
defaults tounknown
because everything can bethrown
in javascript. If you're certain that error is always of a specific type, you can do an explicit type assertion:the safer way would be to let typescript perform type narrowing by doing runtime checks:
I've also written about that here: https://tkdodo.eu/blog/react-query-and-type-script#what-about-error