Make connect return correct type

This commit is contained in:
tkqubo 2015-10-19 22:32:02 +09:00
parent af5b8275d1
commit ddbcdd0d55
2 changed files with 19 additions and 8 deletions

View File

@ -23,13 +23,13 @@ interface CounterState {
declare var increment: Function;
class Counter extends Component<any, any> {
render() {
return (
<button onClick={this.props.onIncrement}>
{this.props.value}
</button>
);
}
render() {
return (
<button onClick={this.props.onIncrement}>
{this.props.value}
</button>
);
}
}
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;

View File

@ -11,7 +11,7 @@ declare module "react-redux" {
import { Store, Dispatch, ActionCreator } from 'redux';
export interface ClassDecorator {
<TFunction extends Function>(target: TFunction): TFunction|void;
<TFunction extends Function>(target: TFunction): TFunction;
}
/**