diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 38c880ba3b..8e2556ec6c 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -78,8 +78,8 @@ export type InferableComponentEnhancer = export interface Connect { (): InferableComponentEnhancer>; - ( - mapStateToProps: MapStateToPropsParam + ( + mapStateToProps: MapStateToPropsParam ): InferableComponentEnhancerWithProps, TOwnProps>; ( @@ -87,13 +87,13 @@ export interface Connect { mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; @@ -110,14 +110,14 @@ export interface Connect { mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: Options @@ -130,15 +130,15 @@ export interface Connect { options: Options ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: Options ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, options: Options @@ -150,15 +150,15 @@ export interface Connect { */ export declare const connect: Connect; -interface MapStateToProps { - (state: any, ownProps: TOwnProps): TStateProps; +interface MapStateToProps { + (state: State, ownProps: TOwnProps): TStateProps; } -interface MapStateToPropsFactory { - (initialState: any, ownProps: TOwnProps): MapStateToProps; +interface MapStateToPropsFactory { + (initialState: State, ownProps: TOwnProps): MapStateToProps; } -type MapStateToPropsParam = MapStateToPropsFactory | MapStateToProps | null | undefined; +type MapStateToPropsParam = MapStateToPropsFactory | MapStateToProps | null | undefined; interface MapDispatchToPropsFunction { (dispatch: Dispatch, ownProps: TOwnProps): TDispatchProps; @@ -177,7 +177,7 @@ interface MergeProps { (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps): TMergedProps; } -interface Options extends ConnectOptions { +interface Options extends ConnectOptions { /** * If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps, * preventing unnecessary updates, assuming that the component is a “pure” component @@ -191,7 +191,7 @@ interface Options extends C * When pure, compares incoming store state to its previous value. * @default strictEqual */ - areStatesEqual?: (nextState: any, prevState: any) => boolean; + areStatesEqual?: (nextState: State, prevState: State) => boolean; /** * When pure, compares incoming props to its previous value. diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index e726bf104f..af77473473 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -316,26 +316,26 @@ interface ICounterDispatchProps { onIncrement: () => void } // with higher order functions -connect( +connect( () => mapStateToProps, () => mapDispatchToProps )(Counter); // with higher order functions using parameters -connect( +connect( (initialState: CounterState, ownProps) => mapStateToProps, (dispatch: Dispatch, ownProps) => mapDispatchToProps )(Counter); // only first argument -connect( +connect( () => mapStateToProps )(Counter); // wrap only one argument -connect( +connect( mapStateToProps, () => mapDispatchToProps )(Counter); // with extra arguments -connect( +connect( () => mapStateToProps, () => mapDispatchToProps, (s: ICounterStateProps, d: ICounterDispatchProps) => @@ -652,7 +652,7 @@ namespace TestTOwnPropsInference { type PickedOwnProps = Pick type PickedStateProps = Pick - const mapStateToPropsForPicked: MapStateToProps = (state: any): PickedStateProps => { + const mapStateToPropsForPicked: MapStateToProps = (state: any): PickedStateProps => { return { state: "string" } } const ConnectedWithPickedOwnProps = connect(mapStateToPropsForPicked)(AllPropsComponent); @@ -878,8 +878,8 @@ namespace TestCreateProvider { interface AProps { a: number }; const A = (props: AProps) => (

A is {props.a}

); - const A1 = connect(state => state)(A); - const A2 = myStoreConnect(state => state)(A); + const A1 = connect(state => state)(A); + const A2 = myStoreConnect(state => state)(A); const Combined = () => (