Make QueryClientConfig generic #3528
-
Current declaration for This makes things hard when your I'd suggest make export interface QueryClientConfig<TError = unknown> {
queryCache?: QueryCache
mutationCache?: MutationCache
defaultOptions?: DefaultOptions<TError>
}
export interface DefaultOptions<TError = unknown> {
queries?: QueryObserverOptions<unknown, TError>
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
is it though? I don't think you can be certain of that. For example, if you have a runtime error in https://tkdodo.eu/blog/react-query-and-type-script#what-about-error |
Beta Was this translation helpful? Give feedback.
is it though? I don't think you can be certain of that. For example, if you have a runtime error in
select
, your query will also go intoError
state with that error. A simpleinstanceOf Error
check, or to use a runtime type guard from axios (axios.isAxiosError(error)
) is one line of code.https://tkdodo.eu/blog/react-query-and-type-script#what-about-error