@@ -78,7 +78,10 @@ describe('type tests', () => {
78
78
} ) ,
79
79
{ type : 'action' } ,
80
80
) as PayloadActionCreator
81
- const actionCreator : ActionCreator < UnknownAction > = payloadActionCreator
81
+
82
+ expectTypeOf ( payloadActionCreator ) . toMatchTypeOf <
83
+ ActionCreator < UnknownAction >
84
+ > ( )
82
85
83
86
const payloadActionCreator2 = Object . assign (
84
87
( payload ?: number ) => ( {
@@ -88,8 +91,9 @@ describe('type tests', () => {
88
91
{ type : 'action' } ,
89
92
) as PayloadActionCreator < number >
90
93
91
- const actionCreator2 : ActionCreator < PayloadAction < number > > =
92
- payloadActionCreator2
94
+ expectTypeOf ( payloadActionCreator2 ) . toMatchTypeOf <
95
+ ActionCreator < PayloadAction < number > >
96
+ > ( )
93
97
} )
94
98
} )
95
99
@@ -104,6 +108,7 @@ describe('type tests', () => {
104
108
105
109
test ( 'createAction() type parameter is required, not inferred (defaults to `void`).' , ( ) => {
106
110
const increment = createAction ( 'increment' )
111
+
107
112
expectTypeOf ( increment ) . parameter ( 0 ) . not . toBeNumber ( )
108
113
109
114
expectTypeOf ( increment ( ) . payload ) . not . toBeNumber ( )
@@ -279,10 +284,6 @@ describe('type tests', () => {
279
284
expectTypeOf ( x . filter ( actionCreator . match ) ) . toEqualTypeOf <
280
285
PayloadAction < string , 'test' > [ ]
281
286
> ( )
282
-
283
- expectTypeOf ( x . filter ( actionCreator . match ) ) . not . toEqualTypeOf <
284
- PayloadAction < number , 'test' > [ ]
285
- > ( )
286
287
} )
287
288
} )
288
289
} )
@@ -319,6 +320,7 @@ describe('type tests', () => {
319
320
320
321
test ( "Verify action creators should not be passed directly as arguments to React event handlers if there shouldn't be a payload" , ( ) => {
321
322
const emptyAction = createAction < void > ( 'empty/action' )
323
+
322
324
function TestComponent ( ) {
323
325
// This typically leads to an error like:
324
326
// // A non-serializable value was detected in an action, in the path: `payload`.
0 commit comments