diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx
index 2ffb30169..4158a035e 100644
--- a/react-redux/react-redux-tests.tsx
+++ b/react-redux/react-redux-tests.tsx
@@ -284,3 +284,47 @@ function HelloMessage(props: HelloMessageProps) {
let ConnectedHelloMessage = connect()(HelloMessage);
ReactDOM.render(, document.getElementById('content'));
ReactDOM.render(, document.getElementById('content'));
+
+// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/8787
+namespace TestTOwnPropsInference {
+ interface OwnProps {
+ own: string;
+ }
+
+ interface StateProps {
+ state: string;
+ }
+
+ class OwnPropsComponent extends React.Component {
+ render() {
+ return ;
+ }
+ }
+
+ function mapStateToPropsWithoutOwnProps(state: any): StateProps {
+ return { state: 'string' };
+ }
+
+ function mapStateToPropsWithOwnProps(state: any, ownProps: OwnProps): StateProps {
+ return { state: 'string' };
+ }
+
+ const ConnectedWithoutOwnProps = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent);
+ const ConnectedWithOwnProps = connect(mapStateToPropsWithOwnProps)(OwnPropsComponent);
+ const ConnectedWithTypeHint = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent);
+
+ // This compiles, which is bad.
+ React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' });
+
+ // This compiles, as expected.
+ React.createElement(ConnectedWithOwnProps, { own: 'string' });
+
+ // This should not compile, which is good.
+ // React.createElement(ConnectedWithOwnProps, { missingOwn: true });
+
+ // This compiles, as expected.
+ React.createElement(ConnectedWithTypeHint, { own: 'string' });
+
+ // This should not compile, which is good.
+ // React.createElement(ConnectedWithTypeHint, { missingOwn: true });
+}
diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts
index 89d33cf6d..0e7810e35 100644
--- a/react-redux/react-redux.d.ts
+++ b/react-redux/react-redux.d.ts
@@ -1,16 +1,16 @@
// Type definitions for react-redux 4.4.0
// Project: https://github.com/rackt/react-redux
-// Definitions by: Qubo
+// Definitions by: Qubo , Sean Kelley
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
///
declare module "react-redux" {
- import { ComponentClass, Component, StatelessComponent, Props, ReactNode } from 'react';
+ import { ComponentClass, Component, StatelessComponent, ReactNode } from 'react';
import { Store, Dispatch, ActionCreator } from 'redux';
- interface ComponentDecorator, TOwnProps extends Props> {
+ interface ComponentDecorator {
(component: ComponentClass): ComponentClass;
}
@@ -43,19 +43,13 @@ declare module "react-redux" {
* @param options
*/
export function connect(): InferableComponentDecorator;
- export function connect<
- TStateProps extends Props,
- TDispatchProps extends Props,
- TOwnProps extends Props
- >(
+
+ export function connect(
mapStateToProps: MapStateToProps,
mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject
): ComponentDecorator;
- export function connect<
- TStateProps extends Props,
- TDispatchProps extends Props,
- TOwnProps extends Props
- >(
+
+ export function connect(
mapStateToProps: MapStateToProps,
mapDispatchToProps: MapDispatchToPropsFunction|MapDispatchToPropsObject,
mergeProps: MergeProps,
@@ -89,7 +83,7 @@ declare module "react-redux" {
pure: boolean;
}
- export interface ProviderProps extends Props {
+ export interface ProviderProps {
/**
* The single Redux store in your application.
*/