From 77a37a7faba9b7598d07313a590bfc617b195764 Mon Sep 17 00:00:00 2001 From: Karlis Gangis Date: Sat, 25 Nov 2017 22:07:37 +0200 Subject: [PATCH] react-redux: fix Options generic type arguments in connect() --- types/react-redux/index.d.ts | 10 +++++----- types/react-redux/react-redux-tests.tsx | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 8e2556ec6c..2a015389da 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -120,28 +120,28 @@ export interface Connect { mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: null | undefined, - options: Options + options: Options ): InferableComponentEnhancerWithProps & TStateProps, TOwnProps>; - ( + ( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, - options: Options + options: Options<{}, TStateProps, TOwnProps> ): InferableComponentEnhancerWithProps; ( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, - options: Options + options: Options ): InferableComponentEnhancerWithProps; ( mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, - options: Options + options: Options ): InferableComponentEnhancerWithProps; } diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index af77473473..393c4d09da 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -247,22 +247,26 @@ namespace MapStateAndDispatchAndMerge { } namespace MapStateAndOptions { + interface State { state: string; } interface OwnProps { foo: string } interface StateProps { bar: number } interface DispatchProps { dispatch: Dispatch } class TestComponent extends Component {} - const mapStateToProps = () => ({ + const mapStateToProps = (state: State) => ({ bar: 1 }) - const Test = connect( + const areStatePropsEqual = (next: StateProps, current: StateProps) => true; + + const Test = connect( mapStateToProps, null, null, { - pure: true + pure: true, + areStatePropsEqual, } )(TestComponent)