diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 112b7e9c95..efbea276f8 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -20,7 +20,11 @@ export interface DispatchProp { } interface ComponentDecorator { - (component: Component): ComponentClass; + (component: Component): ComponentClass; +} + +interface ComponentDecoratorInfer { + (component: Component): ComponentClass; } interface ComponentMergeDecorator { @@ -46,7 +50,7 @@ interface ComponentMergeDecorator { * @param mergeProps * @param options */ -export declare function connect(): ComponentDecorator, {}>; +export declare function connect(): ComponentDecoratorInfer>; export declare function connect( mapStateToProps: MapStateToPropsParam diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index 5875fe9291..7e5ac0f6ae 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -2,7 +2,7 @@ import { Component, ReactElement } from 'react'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { Store, Dispatch, bindActionCreators } from 'redux'; -import { connect, Provider, DispatchProp } from 'react-redux'; +import { connect, Provider, DispatchProp, MapStateToProps } from 'react-redux'; import objectAssign = require('object-assign'); // @@ -375,6 +375,26 @@ namespace TestTOwnPropsInference { // This should not compile, which is good. // React.createElement(ConnectedWithTypeHint, { anything: 'goes!' }); + + interface AllProps { + own: string + state: string + } + + class AllPropsComponent extends React.Component, void> { + render() { + return
; + } + } + + type PickedOwnProps = Pick + type PickedStateProps = Pick + + const mapStateToPropsForPicked: MapStateToProps = (state: any): PickedStateProps => { + return { state: "string" } + } + const ConnectedWithPickedOwnProps = connect(mapStateToPropsForPicked)(AllPropsComponent); + } // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/16021