@@ -599,9 +599,20 @@ const value = actionCreators.anyKey
599
599
} > ( )
600
600
601
601
return {
602
- normalReducer : create . reducer < string > ( ( state , action ) => {
602
+ normalReducer : create . reducer (
603
+ ( state , action : PayloadAction < string > ) => {
604
+ expectType < TestState > ( state )
605
+ expectType < string > ( action . payload )
606
+ }
607
+ ) ,
608
+ optionalReducer : create . reducer (
609
+ ( state , action : PayloadAction < string | undefined > ) => {
610
+ expectType < TestState > ( state )
611
+ expectType < string | undefined > ( action . payload )
612
+ }
613
+ ) ,
614
+ noActionReducer : create . reducer ( ( state ) => {
603
615
expectType < TestState > ( state )
604
- expectType < string > ( action . payload )
605
616
} ) ,
606
617
preparedReducer : create . preparedReducer (
607
618
( payload : string ) => ( {
@@ -707,6 +718,23 @@ const value = actionCreators.anyKey
707
718
type StoreDispatch = typeof store . dispatch
708
719
709
720
expectType < PayloadActionCreator < string > > ( slice . actions . normalReducer )
721
+ slice . actions . normalReducer ( '' )
722
+ // @ts -expect-error
723
+ slice . actions . normalReducer ( )
724
+ // @ts -expect-error
725
+ slice . actions . normalReducer ( 0 )
726
+ expectType < ActionCreatorWithOptionalPayload < string | undefined > > (
727
+ slice . actions . optionalReducer
728
+ )
729
+ slice . actions . optionalReducer ( )
730
+ slice . actions . optionalReducer ( '' )
731
+ // @ts -expect-error
732
+ slice . actions . optionalReducer ( 0 )
733
+
734
+ expectType < ActionCreatorWithoutPayload > ( slice . actions . noActionReducer )
735
+ slice . actions . noActionReducer ( )
736
+ // @ts -expect-error
737
+ slice . actions . noActionReducer ( '' )
710
738
expectType <
711
739
ActionCreatorWithPreparedPayload <
712
740
[ string ] ,
0 commit comments