Skip to content

Commit 3a5074c

Browse files
committed
Make TypeScript slightly happier inside configureStore.test.ts
1 parent 489b096 commit 3a5074c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/toolkit/src/tests/configureStore.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import * as DevTools from '@internal/devtoolsExtension'
22
import type { StoreEnhancer } from '@reduxjs/toolkit'
33
import { Tuple } from '@reduxjs/toolkit'
44
import type * as Redux from 'redux'
5+
import type { MockInstance } from 'vitest'
56
import { vi } from 'vitest'
67

7-
vi.doMock('redux', async () => {
8-
const redux: any = await vi.importActual('redux')
8+
vi.doMock('redux', async (importOriginal) => {
9+
const redux = await importOriginal<typeof import('redux')>()
910

1011
vi.spyOn(redux, 'applyMiddleware')
1112
vi.spyOn(redux, 'combineReducers')
@@ -15,10 +16,19 @@ vi.doMock('redux', async () => {
1516
return redux
1617
})
1718

19+
declare global {
20+
interface Window {
21+
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: MockInstance<
22+
Parameters<typeof DevTools.composeWithDevTools>,
23+
ReturnType<typeof DevTools.composeWithDevTools>
24+
>
25+
}
26+
}
27+
1828
describe('configureStore', async () => {
1929
const composeWithDevToolsSpy = vi.spyOn(DevTools, 'composeWithDevTools')
2030

21-
;(window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = composeWithDevToolsSpy
31+
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = composeWithDevToolsSpy
2232

2333
const redux = await import('redux')
2434

0 commit comments

Comments
 (0)