@@ -154,6 +154,16 @@ interface EndpointDefinitionWithQueryFn<
154
154
structuralSharing ?: boolean
155
155
}
156
156
157
+ export interface BaseEndpointTypes <
158
+ QueryArg ,
159
+ BaseQuery extends BaseQueryFn ,
160
+ ResultType
161
+ > {
162
+ QueryArg : QueryArg
163
+ BaseQuery : BaseQuery
164
+ ResultType : ResultType
165
+ }
166
+
157
167
export type BaseEndpointDefinition <
158
168
QueryArg ,
159
169
BaseQuery extends BaseQueryFn ,
@@ -221,6 +231,31 @@ export interface QueryApi<ReducerPath extends string, Context extends {}> {
221
231
context : Context
222
232
}
223
233
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
+
224
259
export interface QueryExtraOptions <
225
260
TagTypes extends string ,
226
261
ResultType ,
@@ -303,6 +338,11 @@ export interface QueryExtraOptions<
303
338
currentCacheData : ResultType ,
304
339
responseData : ResultType
305
340
) : 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 >
306
346
}
307
347
308
348
export type QueryDefinition <
@@ -314,6 +354,31 @@ export type QueryDefinition<
314
354
> = BaseEndpointDefinition < QueryArg , BaseQuery , ResultType > &
315
355
QueryExtraOptions < TagTypes , ResultType , QueryArg , BaseQuery , ReducerPath >
316
356
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
+
317
382
export interface MutationExtraOptions <
318
383
TagTypes extends string ,
319
384
ResultType ,
@@ -378,6 +443,11 @@ export interface MutationExtraOptions<
378
443
* Not to be used. A mutation should not provide tags to the cache.
379
444
*/
380
445
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 >
381
451
}
382
452
383
453
export type MutationDefinition <
0 commit comments