@@ -806,10 +806,15 @@ describe('createActionListenerMiddleware', () => {
806
806
} )
807
807
808
808
middleware . addListener ( {
809
- predicate : ( action , currentState ) : action is PayloadAction < number > => {
810
- return typeof action . payload === 'number'
809
+ predicate : (
810
+ action ,
811
+ currentState ,
812
+ previousState
813
+ ) : action is PayloadAction < number > => {
814
+ return typeof action . payload === 'boolean'
811
815
} ,
812
816
listener : ( action , listenerApi ) => {
817
+ // @ts -expect-error
813
818
expectExactType < PayloadAction < number > > ( action )
814
819
} ,
815
820
} )
@@ -878,12 +883,18 @@ describe('createActionListenerMiddleware', () => {
878
883
879
884
// Can pass a predicate function with fewer args
880
885
typedMiddleware . addListener ( {
881
- predicate : ( action , currentState ) : action is AnyAction => {
886
+ // TODO Why won't this infer the listener's `action` with implicit argument types?
887
+ predicate : (
888
+ action : AnyAction ,
889
+ currentState : CounterState
890
+ ) : action is PayloadAction < number > => {
882
891
expectNotAny ( currentState )
883
892
expectExactType < CounterState > ( currentState )
884
893
return true
885
894
} ,
886
895
listener : ( action , listenerApi ) => {
896
+ expectType < PayloadAction < number > > ( action )
897
+
887
898
const listenerState = listenerApi . getState ( )
888
899
expectExactType < CounterState > ( listenerState )
889
900
listenerApi . dispatch ( ( dispatch , getState ) => {
0 commit comments