diff --git a/packages/query-core/src/types.ts b/packages/query-core/src/types.ts index a82ea0c6be..bdad93a612 100644 --- a/packages/query-core/src/types.ts +++ b/packages/query-core/src/types.ts @@ -9,6 +9,8 @@ import type { MutationCache } from './mutationCache' export interface Register { // defaultError: Error + // queryMeta: Record + // mutationMeta: Record } export type RegisteredError = Register extends { @@ -72,9 +74,11 @@ export interface InfiniteData { pageParams: unknown[] } -export interface QueryMeta { - [index: string]: unknown +export type QueryMeta = Register extends { + queryMeta: infer TQueryMeta } + ? TQueryMeta + : Record export type NetworkMode = 'online' | 'always' | 'offlineFirst' @@ -583,9 +587,11 @@ export type MutationKey = readonly unknown[] export type MutationStatus = 'idle' | 'pending' | 'success' | 'error' -export interface MutationMeta { - [index: string]: unknown +export type MutationMeta = Register extends { + mutationMeta: infer TMutationMeta } + ? TMutationMeta + : Record export type MutationFunction = ( variables: TVariables,