diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 022b61bff0..8e2556ec6c 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 { +interface MapStateToProps { (state: State, ownProps: TOwnProps): TStateProps; } -interface MapStateToPropsFactory { - (initialState: State, 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; diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index a95d9a6074..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) => @@ -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 = () => (