@@ -3,7 +3,7 @@ import verifySubselectors from './verifySubselectors'
33import type { EqualityFn } from '../types'
44
55export type SelectorFactory < S , TProps , TOwnProps , TFactoryOptions > = (
6- dispatch : Dispatch < Action > ,
6+ dispatch : Dispatch < Action < unknown > > ,
77 factoryOptions : TFactoryOptions
88) => Selector < S , TProps , TOwnProps >
99
@@ -13,24 +13,24 @@ export type Selector<S, TProps, TOwnProps = null> = TOwnProps extends
1313 ? ( state : S ) => TProps
1414 : ( state : S , ownProps : TOwnProps ) => TProps
1515
16- export type MapStateToProps < TStateProps , TOwnProps , State = unknown > = (
16+ export type MapStateToProps < TStateProps , TOwnProps , State > = (
1717 state : State ,
1818 ownProps : TOwnProps
1919) => TStateProps
2020
21- export type MapStateToPropsFactory < TStateProps , TOwnProps , State = unknown > = (
21+ export type MapStateToPropsFactory < TStateProps , TOwnProps , State > = (
2222 initialState : State ,
2323 ownProps : TOwnProps
2424) => MapStateToProps < TStateProps , TOwnProps , State >
2525
26- export type MapStateToPropsParam < TStateProps , TOwnProps , State = unknown > =
26+ export type MapStateToPropsParam < TStateProps , TOwnProps , State > =
2727 | MapStateToPropsFactory < TStateProps , TOwnProps , State >
2828 | MapStateToProps < TStateProps , TOwnProps , State >
2929 | null
3030 | undefined
3131
3232export type MapDispatchToPropsFunction < TDispatchProps , TOwnProps > = (
33- dispatch : Dispatch < Action > ,
33+ dispatch : Dispatch < Action < unknown > > ,
3434 ownProps : TOwnProps
3535) => TDispatchProps
3636
@@ -39,7 +39,7 @@ export type MapDispatchToProps<TDispatchProps, TOwnProps> =
3939 | TDispatchProps
4040
4141export type MapDispatchToPropsFactory < TDispatchProps , TOwnProps > = (
42- dispatch : Dispatch < Action > ,
42+ dispatch : Dispatch < Action < unknown > > ,
4343 ownProps : TOwnProps
4444) => MapDispatchToPropsFunction < TDispatchProps , TOwnProps >
4545
@@ -57,10 +57,10 @@ export type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = (
5757 ownProps : TOwnProps
5858) => TMergedProps
5959
60- interface PureSelectorFactoryComparisonOptions < TOwnProps , State = unknown > {
60+ interface PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State > {
6161 areStatesEqual : EqualityFn < State >
6262 areOwnPropsEqual : EqualityFn < TOwnProps >
63- areStatePropsEqual : EqualityFn < unknown >
63+ areStatePropsEqual : EqualityFn < TStateProps >
6464 displayName : string
6565}
6666
@@ -69,21 +69,17 @@ export function pureFinalPropsSelectorFactory<
6969 TOwnProps ,
7070 TDispatchProps ,
7171 TMergedProps ,
72- State = unknown
72+ State
7373> (
74- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > & {
75- dependsOnOwnProps : boolean
76- } ,
77- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > & {
78- dependsOnOwnProps : boolean
79- } ,
74+ mapStateToProps : WrappedMapStateToProps < TStateProps , TOwnProps , State > ,
75+ mapDispatchToProps : WrappedMapDispatchToProps < TDispatchProps , TOwnProps > ,
8076 mergeProps : MergeProps < TStateProps , TDispatchProps , TOwnProps , TMergedProps > ,
81- dispatch : Dispatch ,
77+ dispatch : Dispatch < Action < unknown > > ,
8278 {
8379 areStatesEqual,
8480 areOwnPropsEqual,
8581 areStatePropsEqual,
86- } : PureSelectorFactoryComparisonOptions < TOwnProps , State >
82+ } : PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State >
8783) {
8884 let hasRunAtLeastOnce = false
8985 let state : State
@@ -95,34 +91,28 @@ export function pureFinalPropsSelectorFactory<
9591 function handleFirstCall ( firstState : State , firstOwnProps : TOwnProps ) {
9692 state = firstState
9793 ownProps = firstOwnProps
98- // @ts -ignore
99- stateProps = mapStateToProps ! ( state , ownProps )
100- // @ts -ignore
101- dispatchProps = mapDispatchToProps ! ( dispatch , ownProps )
94+ stateProps = mapStateToProps ( state , ownProps )
95+ dispatchProps = mapDispatchToProps ( dispatch , ownProps )
10296 mergedProps = mergeProps ( stateProps , dispatchProps , ownProps )
10397 hasRunAtLeastOnce = true
10498 return mergedProps
10599 }
106100
107101 function handleNewPropsAndNewState ( ) {
108- // @ts -ignore
109- stateProps = mapStateToProps ! ( state , ownProps )
102+ stateProps = mapStateToProps ( state , ownProps )
110103
111- if ( mapDispatchToProps ! . dependsOnOwnProps )
112- // @ts -ignore
104+ if ( mapDispatchToProps . dependsOnOwnProps )
113105 dispatchProps = mapDispatchToProps ( dispatch , ownProps )
114106
115107 mergedProps = mergeProps ( stateProps , dispatchProps , ownProps )
116108 return mergedProps
117109 }
118110
119111 function handleNewProps ( ) {
120- if ( mapStateToProps ! . dependsOnOwnProps )
121- // @ts -ignore
122- stateProps = mapStateToProps ! ( state , ownProps )
112+ if ( mapStateToProps . dependsOnOwnProps )
113+ stateProps = mapStateToProps ( state , ownProps )
123114
124115 if ( mapDispatchToProps . dependsOnOwnProps )
125- // @ts -ignore
126116 dispatchProps = mapDispatchToProps ( dispatch , ownProps )
127117
128118 mergedProps = mergeProps ( stateProps , dispatchProps , ownProps )
@@ -132,7 +122,6 @@ export function pureFinalPropsSelectorFactory<
132122 function handleNewState ( ) {
133123 const nextStateProps = mapStateToProps ( state , ownProps )
134124 const statePropsChanged = ! areStatePropsEqual ( nextStateProps , stateProps )
135- // @ts -ignore
136125 stateProps = nextStateProps
137126
138127 if ( statePropsChanged )
@@ -163,24 +152,34 @@ export function pureFinalPropsSelectorFactory<
163152 }
164153}
165154
155+ interface WrappedMapStateToProps < TStateProps , TOwnProps , State > {
156+ ( state : State , ownProps : TOwnProps ) : TStateProps
157+ readonly dependsOnOwnProps : boolean
158+ }
159+
160+ interface WrappedMapDispatchToProps < TDispatchProps , TOwnProps > {
161+ ( dispatch : Dispatch < Action < unknown > > , ownProps : TOwnProps ) : TDispatchProps
162+ readonly dependsOnOwnProps : boolean
163+ }
164+
166165export interface SelectorFactoryOptions <
167166 TStateProps ,
168167 TOwnProps ,
169168 TDispatchProps ,
170169 TMergedProps ,
171- State = unknown
172- > extends PureSelectorFactoryComparisonOptions < TOwnProps , State > {
170+ State
171+ > extends PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State > {
173172 initMapStateToProps : (
174173 dispatch : Dispatch ,
175- options : PureSelectorFactoryComparisonOptions < TOwnProps , State >
176- ) => MapStateToPropsParam < TStateProps , TOwnProps , State >
174+ options : PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State >
175+ ) => WrappedMapStateToProps < TStateProps , TOwnProps , State >
177176 initMapDispatchToProps : (
178177 dispatch : Dispatch ,
179- options : PureSelectorFactoryComparisonOptions < TOwnProps , State >
180- ) => MapDispatchToPropsParam < TDispatchProps , TOwnProps >
178+ options : PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State >
179+ ) => WrappedMapDispatchToProps < TDispatchProps , TOwnProps >
181180 initMergeProps : (
182181 dispatch : Dispatch ,
183- options : PureSelectorFactoryComparisonOptions < TOwnProps , State >
182+ options : PureSelectorFactoryComparisonOptions < TStateProps , TOwnProps , State >
184183 ) => MergeProps < TStateProps , TDispatchProps , TOwnProps , TMergedProps >
185184}
186185
@@ -195,9 +194,9 @@ export default function finalPropsSelectorFactory<
195194 TOwnProps ,
196195 TDispatchProps ,
197196 TMergedProps ,
198- State = unknown
197+ State
199198> (
200- dispatch : Dispatch < Action > ,
199+ dispatch : Dispatch < Action < unknown > > ,
201200 {
202201 initMapStateToProps,
203202 initMapDispatchToProps,
@@ -225,6 +224,5 @@ export default function finalPropsSelectorFactory<
225224 TDispatchProps ,
226225 TMergedProps ,
227226 State
228- // @ts -ignore
229- > ( mapStateToProps ! , mapDispatchToProps , mergeProps , dispatch , options )
227+ > ( mapStateToProps , mapDispatchToProps , mergeProps , dispatch , options )
230228}
0 commit comments