@@ -154,6 +154,16 @@ interface EndpointDefinitionWithQueryFn<
154154 structuralSharing ?: boolean
155155}
156156
157+ export interface BaseEndpointTypes <
158+ QueryArg ,
159+ BaseQuery extends BaseQueryFn ,
160+ ResultType
161+ > {
162+ QueryArg : QueryArg
163+ BaseQuery : BaseQuery
164+ ResultType : ResultType
165+ }
166+
157167export type BaseEndpointDefinition <
158168 QueryArg ,
159169 BaseQuery extends BaseQueryFn ,
@@ -221,6 +231,31 @@ export interface QueryApi<ReducerPath extends string, Context extends {}> {
221231 context : Context
222232}
223233
234+ export interface QueryTypes <
235+ QueryArg ,
236+ BaseQuery extends BaseQueryFn ,
237+ TagTypes extends string ,
238+ ResultType ,
239+ ReducerPath extends string = string
240+ > extends BaseEndpointTypes < QueryArg , BaseQuery , ResultType > {
241+ /**
242+ * The endpoint definition type. To be used with some internal generic types.
243+ * @example
244+ * ```ts
245+ * const useMyWrappedHook: UseQuery<typeof api.endpoints.query.Types.QueryDefinition> = ...
246+ * ```
247+ */
248+ QueryDefinition : QueryDefinition <
249+ QueryArg ,
250+ BaseQuery ,
251+ TagTypes ,
252+ ResultType ,
253+ ReducerPath
254+ >
255+ TagTypes : TagTypes
256+ ReducerPath : ReducerPath
257+ }
258+
224259export interface QueryExtraOptions <
225260 TagTypes extends string ,
226261 ResultType ,
@@ -303,6 +338,11 @@ export interface QueryExtraOptions<
303338 currentCacheData : ResultType ,
304339 responseData : ResultType
305340 ) : ResultType | void
341+
342+ /**
343+ * All of these are `undefined` at runtime, purely to be used in TypeScript declarations!
344+ */
345+ Types ?: QueryTypes < QueryArg , BaseQuery , TagTypes , ResultType , ReducerPath >
306346}
307347
308348export type QueryDefinition <
@@ -314,6 +354,31 @@ export type QueryDefinition<
314354> = BaseEndpointDefinition < QueryArg , BaseQuery , ResultType > &
315355 QueryExtraOptions < TagTypes , ResultType , QueryArg , BaseQuery , ReducerPath >
316356
357+ export interface MutationTypes <
358+ QueryArg ,
359+ BaseQuery extends BaseQueryFn ,
360+ TagTypes extends string ,
361+ ResultType ,
362+ ReducerPath extends string = string
363+ > extends BaseEndpointTypes < QueryArg , BaseQuery , ResultType > {
364+ /**
365+ * The endpoint definition type. To be used with some internal generic types.
366+ * @example
367+ * ```ts
368+ * const useMyWrappedHook: UseMutation<typeof api.endpoints.query.Types.MutationDefinition> = ...
369+ * ```
370+ */
371+ MutationDefinition : MutationDefinition <
372+ QueryArg ,
373+ BaseQuery ,
374+ TagTypes ,
375+ ResultType ,
376+ ReducerPath
377+ >
378+ TagTypes : TagTypes
379+ ReducerPath : ReducerPath
380+ }
381+
317382export interface MutationExtraOptions <
318383 TagTypes extends string ,
319384 ResultType ,
@@ -378,6 +443,11 @@ export interface MutationExtraOptions<
378443 * Not to be used. A mutation should not provide tags to the cache.
379444 */
380445 providesTags ?: never
446+
447+ /**
448+ * All of these are `undefined` at runtime, purely to be used in TypeScript declarations!
449+ */
450+ Types ?: MutationTypes < QueryArg , BaseQuery , TagTypes , ResultType , ReducerPath >
381451}
382452
383453export type MutationDefinition <
0 commit comments