@@ -511,11 +511,12 @@ export type RemoveListenerOverloads<
511
511
unknown ,
512
512
UnknownAction
513
513
> ,
514
+ ExtraArgument = unknown ,
514
515
> = AddListenerOverloads <
515
516
boolean ,
516
517
StateType ,
517
518
DispatchType ,
518
- any ,
519
+ ExtraArgument ,
519
520
UnsubscribeListenerOptions
520
521
>
521
522
@@ -556,22 +557,23 @@ export type TypedAddListener<
556
557
> & {
557
558
/**
558
559
* Creates a "pre-typed" version of `addListener`
559
- * where the `state` and `dispatch ` types are predefined.
560
+ * where the `state`, `dispatch` and `extra ` types are predefined.
560
561
*
561
- * This allows you to set the `state` and `dispatch ` types once,
562
+ * This allows you to set the `state`, `dispatch` and `extra ` types once,
562
563
* eliminating the need to specify them with every `addListener` call.
563
564
*
564
- * @returns A pre-typed `addListener` with the state and dispatch types already defined.
565
+ * @returns A pre-typed `addListener` with the state, dispatch and extra types already defined.
565
566
*
566
567
* @example
567
568
* ```ts
568
569
* import { addListener } from '@reduxjs/toolkit'
569
570
*
570
- * export const addAppListener = addListener.withTypes<RootState, AppDispatch>()
571
+ * export const addAppListener = addListener.withTypes<RootState, AppDispatch, ExtraArguments >()
571
572
* ```
572
573
*
573
574
* @template OverrideStateType - The specific type of state the middleware listener operates on.
574
575
* @template OverrideDispatchType - The specific type of the dispatch function.
576
+ * @template OverrideExtraArgument - The specific type of the extra object.
575
577
*
576
578
* @since 2.1.0
577
579
*/
@@ -581,8 +583,9 @@ export type TypedAddListener<
581
583
OverrideStateType ,
582
584
unknown ,
583
585
UnknownAction
584
- > ,
585
- > ( ) => TypedAddListener < OverrideStateType , OverrideDispatchType >
586
+ > ,
587
+ OverrideExtraArgument = unknown ,
588
+ > ( ) => TypedAddListener < OverrideStateType , OverrideDispatchType , OverrideExtraArgument >
586
589
}
587
590
588
591
/**
@@ -597,34 +600,41 @@ export type TypedRemoveListener<
597
600
unknown ,
598
601
UnknownAction
599
602
> ,
603
+ ExtraArgument = unknown ,
600
604
Payload = ListenerEntry < StateType , DispatchType > ,
601
605
T extends string = 'listenerMiddleware/remove' ,
602
606
> = BaseActionCreator < Payload , T > &
603
607
AddListenerOverloads <
604
608
PayloadAction < Payload , T > ,
605
609
StateType ,
606
610
DispatchType ,
607
- any ,
611
+ ExtraArgument ,
608
612
UnsubscribeListenerOptions
609
613
> & {
610
614
/**
611
615
* Creates a "pre-typed" version of `removeListener`
612
- * where the `state` and `dispatch ` types are predefined.
616
+ * where the `state`, `dispatch` and `extra ` types are predefined.
613
617
*
614
- * This allows you to set the `state` and `dispatch ` types once,
618
+ * This allows you to set the `state`, `dispatch` and `extra ` types once,
615
619
* eliminating the need to specify them with every `removeListener` call.
616
620
*
617
- * @returns A pre-typed `removeListener` with the state and dispatch types already defined.
621
+ * @returns A pre-typed `removeListener` with the state, dispatch and extra
622
+ * types already defined.
618
623
*
619
624
* @example
620
625
* ```ts
621
626
* import { removeListener } from '@reduxjs/toolkit'
622
627
*
623
- * export const removeAppListener = removeListener.withTypes<RootState, AppDispatch>()
628
+ * export const removeAppListener = removeListener.withTypes<
629
+ * RootState,
630
+ * AppDispatch,
631
+ * ExtraArguments
632
+ * >()
624
633
* ```
625
634
*
626
635
* @template OverrideStateType - The specific type of state the middleware listener operates on.
627
636
* @template OverrideDispatchType - The specific type of the dispatch function.
637
+ * @template OverrideExtraArgument - The specific type of the extra object.
628
638
*
629
639
* @since 2.1.0
630
640
*/
@@ -635,7 +645,8 @@ export type TypedRemoveListener<
635
645
unknown ,
636
646
UnknownAction
637
647
> ,
638
- > ( ) => TypedRemoveListener < OverrideStateType , OverrideDispatchType >
648
+ OverrideExtraArgument = unknown ,
649
+ > ( ) => TypedRemoveListener < OverrideStateType , OverrideDispatchType , OverrideExtraArgument >
639
650
}
640
651
641
652
/**
@@ -660,13 +671,13 @@ export type TypedStartListening<
660
671
/**
661
672
* Creates a "pre-typed" version of
662
673
* {@linkcode ListenerMiddlewareInstance.startListening startListening}
663
- * where the `state` and `dispatch ` types are predefined.
674
+ * where the `state`, `dispatch` and `extra ` types are predefined.
664
675
*
665
- * This allows you to set the `state` and `dispatch ` types once,
676
+ * This allows you to set the `state`, `dispatch` and `extra ` types once,
666
677
* eliminating the need to specify them with every
667
678
* {@linkcode ListenerMiddlewareInstance.startListening startListening} call.
668
679
*
669
- * @returns A pre-typed `startListening` with the state and dispatch types already defined.
680
+ * @returns A pre-typed `startListening` with the state, dispatch and extra types already defined.
670
681
*
671
682
* @example
672
683
* ```ts
@@ -676,12 +687,14 @@ export type TypedStartListening<
676
687
*
677
688
* export const startAppListening = listenerMiddleware.startListening.withTypes<
678
689
* RootState,
679
- * AppDispatch
690
+ * AppDispatch,
691
+ * ExtraArguments
680
692
* >()
681
693
* ```
682
694
*
683
695
* @template OverrideStateType - The specific type of state the middleware listener operates on.
684
696
* @template OverrideDispatchType - The specific type of the dispatch function.
697
+ * @template OverrideExtraArgument - The specific type of the extra object.
685
698
*
686
699
* @since 2.1.0
687
700
*/
@@ -692,7 +705,8 @@ export type TypedStartListening<
692
705
unknown ,
693
706
UnknownAction
694
707
> ,
695
- > ( ) => TypedStartListening < OverrideStateType , OverrideDispatchType >
708
+ OverrideExtraArgument = unknown ,
709
+ > ( ) => TypedStartListening < OverrideStateType , OverrideDispatchType , OverrideExtraArgument >
696
710
}
697
711
698
712
/**
@@ -707,17 +721,18 @@ export type TypedStopListening<
707
721
unknown ,
708
722
UnknownAction
709
723
> ,
710
- > = RemoveListenerOverloads < StateType , DispatchType > & {
724
+ ExtraArgument = unknown ,
725
+ > = RemoveListenerOverloads < StateType , DispatchType , ExtraArgument > & {
711
726
/**
712
727
* Creates a "pre-typed" version of
713
728
* {@linkcode ListenerMiddlewareInstance.stopListening stopListening}
714
- * where the `state` and `dispatch ` types are predefined.
729
+ * where the `state`, `dispatch` and `extra ` types are predefined.
715
730
*
716
- * This allows you to set the `state` and `dispatch ` types once,
731
+ * This allows you to set the `state`, `dispatch` and `extra ` types once,
717
732
* eliminating the need to specify them with every
718
733
* {@linkcode ListenerMiddlewareInstance.stopListening stopListening} call.
719
734
*
720
- * @returns A pre-typed `stopListening` with the state and dispatch types already defined.
735
+ * @returns A pre-typed `stopListening` with the state, dispatch and extra types already defined.
721
736
*
722
737
* @example
723
738
* ```ts
@@ -727,12 +742,14 @@ export type TypedStopListening<
727
742
*
728
743
* export const stopAppListening = listenerMiddleware.stopListening.withTypes<
729
744
* RootState,
730
- * AppDispatch
745
+ * AppDispatch,
746
+ * ExtraArguments
731
747
* >()
732
748
* ```
733
749
*
734
750
* @template OverrideStateType - The specific type of state the middleware listener operates on.
735
751
* @template OverrideDispatchType - The specific type of the dispatch function.
752
+ * @template OverrideExtraArgument - The specific type of the extra object.
736
753
*
737
754
* @since 2.1.0
738
755
*/
@@ -743,7 +760,8 @@ export type TypedStopListening<
743
760
unknown ,
744
761
UnknownAction
745
762
> ,
746
- > ( ) => TypedStopListening < OverrideStateType , OverrideDispatchType >
763
+ OverrideExtraArgument = unknown ,
764
+ > ( ) => TypedStopListening < OverrideStateType , OverrideDispatchType , OverrideExtraArgument >
747
765
}
748
766
749
767
/**
@@ -758,32 +776,37 @@ export type TypedCreateListenerEntry<
758
776
unknown ,
759
777
UnknownAction
760
778
> ,
779
+ ExtraArgument = unknown ,
761
780
> = AddListenerOverloads <
762
781
ListenerEntry < StateType , DispatchType > ,
763
782
StateType ,
764
- DispatchType
783
+ DispatchType ,
784
+ ExtraArgument
765
785
> & {
766
786
/**
767
787
* Creates a "pre-typed" version of `createListenerEntry`
768
- * where the `state` and `dispatch ` types are predefined.
788
+ * where the `state`, `dispatch` and `extra ` types are predefined.
769
789
*
770
- * This allows you to set the `state` and `dispatch ` types once, eliminating
790
+ * This allows you to set the `state`, `dispatch` and `extra ` types once, eliminating
771
791
* the need to specify them with every `createListenerEntry` call.
772
792
*
773
- * @returns A pre-typed `createListenerEntry` with the state and dispatch types already defined.
793
+ * @returns A pre-typed `createListenerEntry` with the state, dispatch and extra
794
+ * types already defined.
774
795
*
775
796
* @example
776
797
* ```ts
777
798
* import { createListenerEntry } from '@reduxjs/toolkit'
778
799
*
779
800
* export const createAppListenerEntry = createListenerEntry.withTypes<
780
801
* RootState,
781
- * AppDispatch
802
+ * AppDispatch,
803
+ * ExtraArguments
782
804
* >()
783
805
* ```
784
806
*
785
807
* @template OverrideStateType - The specific type of state the middleware listener operates on.
786
808
* @template OverrideDispatchType - The specific type of the dispatch function.
809
+ * @template OverrideExtraArgument - The specific type of the extra object.
787
810
*
788
811
* @since 2.1.0
789
812
*/
@@ -794,7 +817,8 @@ export type TypedCreateListenerEntry<
794
817
unknown ,
795
818
UnknownAction
796
819
> ,
797
- > ( ) => TypedStopListening < OverrideStateType , OverrideDispatchType >
820
+ OverrideExtraArgument = unknown ,
821
+ > ( ) => TypedStopListening < OverrideStateType , OverrideDispatchType , OverrideExtraArgument >
798
822
}
799
823
800
824
/**
0 commit comments