Skip to content

Commit 6606e37

Browse files
committed
Remove now-unneeded @ts-expect-error check in listener test
1 parent 54408b0 commit 6606e37

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ describe('createListenerMiddleware', () => {
184184
middleware: (gDM) => gDM().prepend(listenerMiddleware.middleware),
185185
})
186186

187-
let foundExtra: number | null = null
187+
let foundExtra: number | null = null
188188

189189
const typedAddListener =
190190
listenerMiddleware.startListening as TypedStartListening<
@@ -1061,12 +1061,13 @@ describe('createListenerMiddleware', () => {
10611061
middleware: (gDM) => gDM().prepend(middleware),
10621062
})
10631063

1064-
const typedAddListener =
1065-
startListening as TypedStartListening<
1066-
CounterState,
1067-
typeof store.dispatch
1068-
>
1069-
let result: [ReturnType<typeof increment>, CounterState, CounterState] | null = null
1064+
const typedAddListener = startListening as TypedStartListening<
1065+
CounterState,
1066+
typeof store.dispatch
1067+
>
1068+
let result:
1069+
| [ReturnType<typeof increment>, CounterState, CounterState]
1070+
| null = null
10701071

10711072
typedAddListener({
10721073
predicate: incrementByAmount.match,
@@ -1126,31 +1127,34 @@ describe('createListenerMiddleware', () => {
11261127
expect(takeResult).toEqual([increment(), stateCurrent, stateBefore])
11271128
})
11281129

1129-
test("take resolves to `[A, CurrentState, PreviousState] | null` if a possibly undefined timeout parameter is provided", async () => {
1130+
test('take resolves to `[A, CurrentState, PreviousState] | null` if a possibly undefined timeout parameter is provided', async () => {
11301131
const store = configureStore({
11311132
reducer: counterSlice.reducer,
11321133
middleware: (gDM) => gDM().prepend(middleware),
11331134
})
11341135

1135-
type ExpectedTakeResultType = readonly [ReturnType<typeof increment>, CounterState, CounterState] | null
1136+
type ExpectedTakeResultType =
1137+
| readonly [ReturnType<typeof increment>, CounterState, CounterState]
1138+
| null
11361139

11371140
let timeout: number | undefined = undefined
11381141
let done = false
11391142

1140-
const startAppListening = startListening as TypedStartListening<CounterState>
1143+
const startAppListening =
1144+
startListening as TypedStartListening<CounterState>
11411145
startAppListening({
11421146
predicate: incrementByAmount.match,
11431147
effect: async (_, listenerApi) => {
11441148
const stateBefore = listenerApi.getState()
1145-
1149+
11461150
let takeResult = await listenerApi.take(increment.match, timeout)
11471151
const stateCurrent = listenerApi.getState()
11481152
expect(takeResult).toEqual([increment(), stateCurrent, stateBefore])
1149-
1153+
11501154
timeout = 1
11511155
takeResult = await listenerApi.take(increment.match, timeout)
11521156
expect(takeResult).toBeNull()
1153-
1157+
11541158
expectType<ExpectedTakeResultType>(takeResult)
11551159

11561160
done = true
@@ -1160,7 +1164,7 @@ describe('createListenerMiddleware', () => {
11601164
store.dispatch(increment())
11611165

11621166
await delay(25)
1163-
expect(done).toBe(true);
1167+
expect(done).toBe(true)
11641168
})
11651169

11661170
test('condition method resolves promise when the predicate succeeds', async () => {
@@ -1444,7 +1448,6 @@ describe('createListenerMiddleware', () => {
14441448
return typeof action.payload === 'boolean'
14451449
},
14461450
effect: (action, listenerApi) => {
1447-
// @ts-expect-error
14481451
expectExactType<PayloadAction<number>>(action)
14491452
},
14501453
})

0 commit comments

Comments
 (0)