-
I'd like to propose a way to extend the type of the meta field in ProblemDespite trying module augmentation: declare module '@tanstack/react-query' {
export interface QueryOptions {
meta?: {
defaultErrorNotify: string
};
}
} This does not change the type of the meta field in usage like: useQuery({
queryKey: ['mojtaba'],
queryFn: async () => await axios.get('https://httpbin.org/status/401'),
meta: {
defaultErrorNotify: false, // ❌ TypeScript error
},
}); TypeScript still complains that meta must be of type unknown or any. Why this mattersMany applications need to attach custom metadata (e.g. meta: { defaultErrorNotify: false }) to queries for internal tooling (e.g. global error handling). Currently, we lose type-safety or need to cast manually. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
please see the typescript docs, we already support this: https://tanstack.com/query/latest/docs/framework/react/typescript#registering-global-meta |
Beta Was this translation helpful? Give feedback.
please see the typescript docs, we already support this:
https://tanstack.com/query/latest/docs/framework/react/typescript#registering-global-meta