From ddbcdd0d552dca2885123d9e0c430edbc63fab8b Mon Sep 17 00:00:00 2001 From: tkqubo Date: Mon, 19 Oct 2015 22:32:02 +0900 Subject: [PATCH] Make connect return correct type --- react-redux/react-redux-tests.tsx | 25 ++++++++++++++++++------- react-redux/react-redux.d.ts | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 9bd662295a..6dac834206 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -23,13 +23,13 @@ interface CounterState { declare var increment: Function; class Counter extends Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } function mapStateToProps(state: CounterState) { @@ -242,3 +242,14 @@ connect(mapStateToProps2, actionCreators, mergeProps)(TodoApp); + + +// Ensure return value of the connect()(TodoApp) is of the type TodoApp +let WrappedTodoApp: typeof TodoApp = connect()(TodoApp); + +// connect()(SomeClass) has the same constructor as SomeClass itself +class SomeClass { + constructor(public foo: string) { } + 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 f1ef5458e1..03af3e06d8 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -11,7 +11,7 @@ declare module "react-redux" { import { Store, Dispatch, ActionCreator } from 'redux'; export interface ClassDecorator { - (target: TFunction): TFunction|void; + (target: TFunction): TFunction; } /**