@@ -64,6 +64,7 @@ type AppThunk<ThunkReturnType = void> = ThunkAction<
64
64
unknown ,
65
65
Action
66
66
>
67
+ type ExtraArgument = { foo : string }
67
68
68
69
describe ( 'listenerMiddleware.withTypes<RootState, AppDispatch>()' , ( ) => {
69
70
const listenerMiddleware = createListenerMiddleware ( )
@@ -77,11 +78,12 @@ describe('listenerMiddleware.withTypes<RootState, AppDispatch>()', () => {
77
78
test ( 'startListening.withTypes' , ( ) => {
78
79
const startAppListening = listenerMiddleware . startListening . withTypes <
79
80
RootState ,
80
- AppDispatch
81
+ AppDispatch ,
82
+ ExtraArgument
81
83
> ( )
82
84
83
85
expectTypeOf ( startAppListening ) . toEqualTypeOf <
84
- TypedStartListening < RootState , AppDispatch >
86
+ TypedStartListening < RootState , AppDispatch , ExtraArgument >
85
87
> ( )
86
88
87
89
startAppListening ( {
@@ -102,6 +104,8 @@ describe('listenerMiddleware.withTypes<RootState, AppDispatch>()', () => {
102
104
103
105
expectTypeOf ( stateCurrent ) . toEqualTypeOf < RootState > ( )
104
106
107
+ expectTypeOf ( listenerApi . extra ) . toEqualTypeOf < ExtraArgument > ( )
108
+
105
109
timeout = 1
106
110
takeResult = await listenerApi . take ( increment . match , timeout )
107
111
@@ -111,10 +115,14 @@ describe('listenerMiddleware.withTypes<RootState, AppDispatch>()', () => {
111
115
} )
112
116
113
117
test ( 'addListener.withTypes' , ( ) => {
114
- const addAppListener = addListener . withTypes < RootState , AppDispatch > ( )
118
+ const addAppListener = addListener . withTypes <
119
+ RootState ,
120
+ AppDispatch ,
121
+ ExtraArgument
122
+ > ( )
115
123
116
124
expectTypeOf ( addAppListener ) . toEqualTypeOf <
117
- TypedAddListener < RootState , AppDispatch >
125
+ TypedAddListener < RootState , AppDispatch , ExtraArgument >
118
126
> ( )
119
127
120
128
store . dispatch (
@@ -126,27 +134,34 @@ describe('listenerMiddleware.withTypes<RootState, AppDispatch>()', () => {
126
134
expectTypeOf ( state ) . toEqualTypeOf < RootState > ( )
127
135
128
136
expectTypeOf ( listenerApi . dispatch ) . toEqualTypeOf < AppDispatch > ( )
137
+
138
+ expectTypeOf ( listenerApi . extra ) . toEqualTypeOf < ExtraArgument > ( )
129
139
} ,
130
140
} ) ,
131
141
)
132
142
} )
133
143
134
144
test ( 'removeListener.withTypes' , ( ) => {
135
- const removeAppListener = removeListener . withTypes < RootState , AppDispatch > ( )
145
+ const removeAppListener = removeListener . withTypes <
146
+ RootState ,
147
+ AppDispatch ,
148
+ ExtraArgument
149
+ > ( )
136
150
137
151
expectTypeOf ( removeAppListener ) . toEqualTypeOf <
138
- TypedRemoveListener < RootState , AppDispatch >
152
+ TypedRemoveListener < RootState , AppDispatch , ExtraArgument >
139
153
> ( )
140
154
} )
141
155
142
156
test ( 'stopListening.withTypes' , ( ) => {
143
157
const stopAppListening = listenerMiddleware . stopListening . withTypes <
144
158
RootState ,
145
- AppDispatch
159
+ AppDispatch ,
160
+ ExtraArgument
146
161
> ( )
147
162
148
163
expectTypeOf ( stopAppListening ) . toEqualTypeOf <
149
- TypedStopListening < RootState , AppDispatch >
164
+ TypedStopListening < RootState , AppDispatch , ExtraArgument >
150
165
> ( )
151
166
} )
152
167
} )
0 commit comments