diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 38c880ba3b..022b61bff0 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -78,67 +78,67 @@ export type InferableComponentEnhancer = export interface Connect { (): InferableComponentEnhancer>; - ( - mapStateToProps: MapStateToPropsParam + ( + mapStateToProps: MapStateToPropsParam ): InferableComponentEnhancerWithProps, TOwnProps>; - ( + ( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( + ( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( + ( mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, ): InferableComponentEnhancerWithProps; - ( - mapStateToProps: MapStateToPropsParam, + ( + mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: Options ): InferableComponentEnhancerWithProps & TStateProps, TOwnProps>; - ( + ( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, 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..a95d9a6074 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -316,12 +316,12 @@ 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); @@ -330,12 +330,12 @@ connect( () => mapStateToProps )(Counter); // wrap only one argument -connect( +connect( mapStateToProps, () => mapDispatchToProps )(Counter); // with extra arguments -connect( +connect( () => mapStateToProps, () => mapDispatchToProps, (s: ICounterStateProps, d: ICounterDispatchProps) => @@ -621,7 +621,7 @@ namespace TestTOwnPropsInference { const ConnectedWithoutOwnProps = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); const ConnectedWithOwnProps = connect(mapStateToPropsWithOwnProps)(OwnPropsComponent); - const ConnectedWithTypeHint = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); + const ConnectedWithTypeHint = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); // This should not compile, which is good. // React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' }); @@ -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); @@ -691,7 +691,7 @@ namespace TestMergedPropsInference { return { dispatch: 'string' }; } - const ConnectedWithOwnAndState: React.ComponentClass = connect( + const ConnectedWithOwnAndState: React.ComponentClass = connect( mapStateToProps, undefined, (stateProps: StateProps) => ({ @@ -699,7 +699,7 @@ namespace TestMergedPropsInference { }), )(MergedPropsComponent); - const ConnectedWithOwnAndDispatch: React.ComponentClass = connect( + const ConnectedWithOwnAndDispatch: React.ComponentClass = connect( undefined, mapDispatchToProps, (stateProps: undefined, dispatchProps: DispatchProps) => ({ @@ -707,7 +707,7 @@ namespace TestMergedPropsInference { }), )(MergedPropsComponent); - const ConnectedWithOwn: React.ComponentClass = connect( + const ConnectedWithOwn: React.ComponentClass = connect( undefined, undefined, () => ({ @@ -733,7 +733,7 @@ namespace Issue16652 { }; }; - const ConnectedCommentList = connect(mapStateToProps)( + const ConnectedCommentList = connect(mapStateToProps)( CommentList ); @@ -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 = () => (