@@ -52,6 +52,7 @@ import { useStableQueryArgs } from './useSerializedStableValue'
52
52
import type { UninitializedValue } from './constants'
53
53
import { UNINITIALIZED_VALUE } from './constants'
54
54
import { useShallowStableValue } from './useShallowStableValue'
55
+ import { BaseQueryFn } from '../baseQueryTypes'
55
56
56
57
// Copy-pasted from React-Redux
57
58
export const useIsomorphicLayoutEffect =
@@ -97,7 +98,22 @@ export type UseQuery<D extends QueryDefinition<any, any, any, any>> = <
97
98
> (
98
99
arg : QueryArgFrom < D > | SkipToken ,
99
100
options ?: UseQuerySubscriptionOptions & UseQueryStateOptions < D , R >
100
- ) => UseQueryStateResult < D , R > & ReturnType < UseQuerySubscription < D > >
101
+ ) => UseQueryHookResult < D , R >
102
+
103
+ export type UseQueryHookResult <
104
+ D extends QueryDefinition < any , any , any , any > ,
105
+ R = UseQueryStateDefaultResult < D >
106
+ > = UseQueryStateResult < D , R > & UseQuerySubscriptionResult < D >
107
+
108
+ export type TypedUseQueryHookResult <
109
+ ResultType ,
110
+ QueryArg ,
111
+ BaseQuery extends BaseQueryFn ,
112
+ R = UseQueryStateDefaultResult <
113
+ QueryDefinition < QueryArg , BaseQuery , string , ResultType , string >
114
+ >
115
+ > = TypedUseQueryStateResult < ResultType , QueryArg , BaseQuery , R > &
116
+ TypedUseQuerySubscriptionResult < ResultType , QueryArg , BaseQuery >
101
117
102
118
interface UseQuerySubscriptionOptions extends SubscriptionOptions {
103
119
/**
@@ -162,7 +178,19 @@ export type UseQuerySubscription<
162
178
> = (
163
179
arg : QueryArgFrom < D > | SkipToken ,
164
180
options ?: UseQuerySubscriptionOptions
165
- ) => Pick < QueryActionCreatorResult < D > , 'refetch' >
181
+ ) => UseQuerySubscriptionResult < D >
182
+
183
+ export type UseQuerySubscriptionResult <
184
+ D extends QueryDefinition < any , any , any , any >
185
+ > = Pick < QueryActionCreatorResult < D > , 'refetch' >
186
+
187
+ export type TypedUseQuerySubscriptionResult <
188
+ ResultType ,
189
+ QueryArg ,
190
+ BaseQuery extends BaseQueryFn
191
+ > = UseQuerySubscriptionResult <
192
+ QueryDefinition < QueryArg , BaseQuery , string , ResultType , string >
193
+ >
166
194
167
195
export type UseLazyQueryLastPromiseInfo <
168
196
D extends QueryDefinition < any , any , any , any >
@@ -338,6 +366,15 @@ export type UseQueryStateResult<
338
366
R
339
367
> = NoInfer < R >
340
368
369
+ export type TypedUseQueryStateResult <
370
+ ResultType ,
371
+ QueryArg ,
372
+ BaseQuery extends BaseQueryFn ,
373
+ R = UseQueryStateDefaultResult <
374
+ QueryDefinition < QueryArg , BaseQuery , string , ResultType , string >
375
+ >
376
+ > = NoInfer < R >
377
+
341
378
type UseQueryStateBaseResult < D extends QueryDefinition < any , any , any , any > > =
342
379
QuerySubState < D > & {
343
380
/**
@@ -435,6 +472,18 @@ export type UseMutationStateResult<
435
472
reset : ( ) => void
436
473
}
437
474
475
+ export type TypedUseMutationResult <
476
+ ResultType ,
477
+ QueryArg ,
478
+ BaseQuery extends BaseQueryFn ,
479
+ R = MutationResultSelectorResult <
480
+ MutationDefinition < QueryArg , BaseQuery , string , ResultType , string >
481
+ >
482
+ > = UseMutationStateResult <
483
+ MutationDefinition < QueryArg , BaseQuery , string , ResultType , string > ,
484
+ R
485
+ >
486
+
438
487
/**
439
488
* A React hook that lets you trigger an update request for a given endpoint, and subscribes the component to read the request status from the Redux store. The component will re-render as the loading status changes.
440
489
*
0 commit comments