diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 98f649e9f8..32e8919075 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -148,12 +148,8 @@ interface MapDispatchToPropsFunction { (dispatch: Dispatch, ownProps: TOwnProps): TDispatchProps; } -interface MapDispatchToPropsObject { - [name: string]: ActionCreator; -} - type MapDispatchToProps = - MapDispatchToPropsFunction | MapDispatchToPropsObject; + MapDispatchToPropsFunction | TDispatchProps; interface MapDispatchToPropsFactory { (dispatch: Dispatch, ownProps: TOwnProps): MapDispatchToProps; @@ -180,13 +176,13 @@ interface Options extends C * @default strictEqual */ areStatesEqual?: (nextState: any, prevState: any) => boolean; - + /** * When pure, compares incoming props to its previous value. * @default shallowEqual */ areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean; - + /** * When pure, compares the result of mapStateToProps to its previous value. * @default shallowEqual diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index bb927c3333..5a9b038dc5 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -1,7 +1,7 @@ import { Component, ReactElement } from 'react'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import { Store, Dispatch, bindActionCreators } from 'redux'; +import { Store, Dispatch, ActionCreator, bindActionCreators } from 'redux'; import { connect, Provider, DispatchProp, MapStateToProps } from 'react-redux'; import objectAssign = require('object-assign'); @@ -549,3 +549,23 @@ namespace TestControlledComponentWithoutDispatchProp { const MyControlledComponent = connect(mapStateToProps)(MyComponent); const MyControlledFuncComponent = connect(mapStateToProps)(MyFuncComponent); } + +namespace TestDispatchToPropsAsObject { + const onClick: ActionCreator<{}> = null; + const mapStateToProps = (state: any) => { + return { + title: state.app.title as string, + }; + }; + const dispatchToProps = { + onClick, + }; + + type Props = { title: string; } & typeof dispatchToProps; + const HeaderComponent: React.StatelessComponent = (props) => { + return

{props.title}

; + } + + const Header = connect(mapStateToProps, dispatchToProps)(HeaderComponent); +
+}