@@ -207,19 +207,6 @@ export function setupApiStore<
207
207
}
208
208
} = { }
209
209
) {
210
- type State = {
211
- api : ReturnType < A [ 'reducer' ] >
212
- } & {
213
- [ K in keyof R ] : ReturnType < R [ K ] >
214
- }
215
- type StoreType = EnhancedStore <
216
- State ,
217
- AnyAction ,
218
- EnhancerArray <
219
- [ StoreEnhancer < { dispatch : ThunkDispatch < State , unknown , AnyAction > } > ]
220
- >
221
- >
222
-
223
210
const { middleware } = options
224
211
const getStore = ( ) =>
225
212
configureStore ( {
@@ -232,15 +219,28 @@ export function setupApiStore<
232
219
233
220
return tempMiddleware
234
221
. concat ( ...( middleware ?. concat ?? [ ] ) )
235
- . prepend ( ...( middleware ?. prepend ?? [ ] ) ) as any
222
+ . prepend ( ...( middleware ?. prepend ?? [ ] ) ) as typeof tempMiddleware
236
223
} ,
237
224
enhancers : ( gde ) =>
238
225
gde ( {
239
226
autoBatch : false ,
240
227
} ) ,
241
- } ) as StoreType
228
+ } )
229
+
230
+ type State = {
231
+ api : ReturnType < A [ 'reducer' ] >
232
+ } & {
233
+ [ K in keyof R ] : ReturnType < R [ K ] >
234
+ }
235
+ type StoreType = EnhancedStore <
236
+ State ,
237
+ AnyAction ,
238
+ ReturnType < typeof getStore > extends EnhancedStore < any , any , infer E >
239
+ ? E
240
+ : [ ]
241
+ >
242
242
243
- const initialStore = getStore ( )
243
+ const initialStore = getStore ( ) as StoreType
244
244
const refObj = {
245
245
api,
246
246
store : initialStore ,
@@ -250,7 +250,7 @@ export function setupApiStore<
250
250
251
251
if ( ! options . withoutTestLifecycles ) {
252
252
beforeEach ( ( ) => {
253
- const store = getStore ( )
253
+ const store = getStore ( ) as StoreType
254
254
refObj . store = store
255
255
refObj . wrapper = withProvider ( store )
256
256
if ( ! options . withoutListeners ) {
0 commit comments