File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ export interface ActionCreatorWithoutPayload<T extends string = string>
144
144
* Calling this {@link redux#ActionCreator} will
145
145
* return a {@link PayloadAction} of type `T` with a payload of `undefined`
146
146
*/
147
- ( ) : PayloadAction < undefined , T >
147
+ ( noArgument : void ) : PayloadAction < undefined , T >
148
148
}
149
149
150
150
/**
Original file line number Diff line number Diff line change
1
+ import React from 'react'
1
2
import type { Action , AnyAction , ActionCreator } from 'redux'
2
3
import type {
3
4
PayloadAction ,
@@ -344,3 +345,15 @@ import { expectType } from './helpers'
344
345
type AnyPayload = ReturnType < typeof anyCreator > [ 'payload' ]
345
346
expectType < IsAny < AnyPayload , true , false > > ( true )
346
347
}
348
+
349
+ // Verify action creators should not be passed directly as arguments
350
+ // to React event handlers if there shouldn't be a payload
351
+ {
352
+ const emptyAction = createAction < void > ( 'empty/action' )
353
+ function TestComponent ( ) {
354
+ // This typically leads to an error like:
355
+ // // A non-serializable value was detected in an action, in the path: `payload`.
356
+ // @ts -expect-error Should error because `void` and `MouseEvent` aren't compatible
357
+ return < button onClick = { emptyAction } > +</ button >
358
+ }
359
+ }
You can’t perform that action at this time.
0 commit comments