mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Make connect return correct type
This commit is contained in:
parent
af5b8275d1
commit
ddbcdd0d55
@ -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;
|
||||
|
||||
2
react-redux/react-redux.d.ts
vendored
2
react-redux/react-redux.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user