Skip to content

Commit a474da3

Browse files
committed
undo ugliness
1 parent 7c34b06 commit a474da3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

packages/toolkit/src/query/tests/helpers.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,6 @@ export function setupApiStore<
207207
}
208208
} = {}
209209
) {
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-
223210
const { middleware } = options
224211
const getStore = () =>
225212
configureStore({
@@ -232,15 +219,28 @@ export function setupApiStore<
232219

233220
return tempMiddleware
234221
.concat(...(middleware?.concat ?? []))
235-
.prepend(...(middleware?.prepend ?? [])) as any
222+
.prepend(...(middleware?.prepend ?? [])) as typeof tempMiddleware
236223
},
237224
enhancers: (gde) =>
238225
gde({
239226
autoBatch: false,
240227
}),
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+
>
242242

243-
const initialStore = getStore()
243+
const initialStore = getStore() as StoreType
244244
const refObj = {
245245
api,
246246
store: initialStore,
@@ -250,7 +250,7 @@ export function setupApiStore<
250250

251251
if (!options.withoutTestLifecycles) {
252252
beforeEach(() => {
253-
const store = getStore()
253+
const store = getStore() as StoreType
254254
refObj.store = store
255255
refObj.wrapper = withProvider(store)
256256
if (!options.withoutListeners) {

0 commit comments

Comments
 (0)