@@ -184,7 +184,7 @@ describe('createListenerMiddleware', () => {
184
184
middleware : ( gDM ) => gDM ( ) . prepend ( listenerMiddleware . middleware ) ,
185
185
} )
186
186
187
- let foundExtra : number | null = null
187
+ let foundExtra : number | null = null
188
188
189
189
const typedAddListener =
190
190
listenerMiddleware . startListening as TypedStartListening <
@@ -1061,12 +1061,13 @@ describe('createListenerMiddleware', () => {
1061
1061
middleware : ( gDM ) => gDM ( ) . prepend ( middleware ) ,
1062
1062
} )
1063
1063
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
1070
1071
1071
1072
typedAddListener ( {
1072
1073
predicate : incrementByAmount . match ,
@@ -1126,31 +1127,34 @@ describe('createListenerMiddleware', () => {
1126
1127
expect ( takeResult ) . toEqual ( [ increment ( ) , stateCurrent , stateBefore ] )
1127
1128
} )
1128
1129
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 ( ) => {
1130
1131
const store = configureStore ( {
1131
1132
reducer : counterSlice . reducer ,
1132
1133
middleware : ( gDM ) => gDM ( ) . prepend ( middleware ) ,
1133
1134
} )
1134
1135
1135
- type ExpectedTakeResultType = readonly [ ReturnType < typeof increment > , CounterState , CounterState ] | null
1136
+ type ExpectedTakeResultType =
1137
+ | readonly [ ReturnType < typeof increment > , CounterState , CounterState ]
1138
+ | null
1136
1139
1137
1140
let timeout : number | undefined = undefined
1138
1141
let done = false
1139
1142
1140
- const startAppListening = startListening as TypedStartListening < CounterState >
1143
+ const startAppListening =
1144
+ startListening as TypedStartListening < CounterState >
1141
1145
startAppListening ( {
1142
1146
predicate : incrementByAmount . match ,
1143
1147
effect : async ( _ , listenerApi ) => {
1144
1148
const stateBefore = listenerApi . getState ( )
1145
-
1149
+
1146
1150
let takeResult = await listenerApi . take ( increment . match , timeout )
1147
1151
const stateCurrent = listenerApi . getState ( )
1148
1152
expect ( takeResult ) . toEqual ( [ increment ( ) , stateCurrent , stateBefore ] )
1149
-
1153
+
1150
1154
timeout = 1
1151
1155
takeResult = await listenerApi . take ( increment . match , timeout )
1152
1156
expect ( takeResult ) . toBeNull ( )
1153
-
1157
+
1154
1158
expectType < ExpectedTakeResultType > ( takeResult )
1155
1159
1156
1160
done = true
@@ -1160,7 +1164,7 @@ describe('createListenerMiddleware', () => {
1160
1164
store . dispatch ( increment ( ) )
1161
1165
1162
1166
await delay ( 25 )
1163
- expect ( done ) . toBe ( true ) ;
1167
+ expect ( done ) . toBe ( true )
1164
1168
} )
1165
1169
1166
1170
test ( 'condition method resolves promise when the predicate succeeds' , async ( ) => {
@@ -1444,7 +1448,6 @@ describe('createListenerMiddleware', () => {
1444
1448
return typeof action . payload === 'boolean'
1445
1449
} ,
1446
1450
effect : ( action , listenerApi ) => {
1447
- // @ts -expect-error
1448
1451
expectExactType < PayloadAction < number > > ( action )
1449
1452
} ,
1450
1453
} )
0 commit comments