diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 6dac834206..abbacabef2 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -4,7 +4,7 @@ /// /// -import { Component } from 'react'; +import { Component, ReactElement } from 'react'; import * as React from 'react'; import * as Router from 'react-router'; import { Route, RouterState } from 'react-router'; @@ -244,12 +244,35 @@ connect(mapStateToProps2, actionCreators, mergeProps)(TodoApp); -// Ensure return value of the connect()(TodoApp) is of the type TodoApp -let WrappedTodoApp: typeof TodoApp = connect()(TodoApp); +interface TestProp { + property1: number; + someOtherProperty?: string; +} +interface TestState { + isLoaded: boolean; + state1: number; +} +class TestComponent extends Component { } +const WrappedTestComponent = connect()(TestComponent); + +// return value of the connect()(TestComponent) is of the type TestComponent +let ATestComponent: typeof TestComponent = null; +ATestComponent = TestComponent; +ATestComponent = WrappedTestComponent; + +let anElement: ReactElement; +; +; +; + +class NonComponent {} +// this doesn't compile +//connect()(NonComponent); // connect()(SomeClass) has the same constructor as SomeClass itself -class SomeClass { - constructor(public foo: string) { } +class SomeClass extends Component { + constructor(public foo: string) { super() } public bar: number; } let bar: number = new (connect()(SomeClass))("foo").bar; + diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts index 03af3e06d8..767b6b1097 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -10,8 +10,9 @@ declare module "react-redux" { import { Component } from 'react'; import { Store, Dispatch, ActionCreator } from 'redux'; + export class ElementClass extends Component { } export interface ClassDecorator { - (target: TFunction): TFunction; + (component: T): T } /**