// @strict: true declare class Component

{ constructor(props: Readonly

); constructor(props: P, context?: any); readonly props: Readonly

& Readonly<{ children?: {} }>; } interface ComponentClass

{ new (props: P, context?: any): Component

; propTypes?: WeakValidationMap

; defaultProps?: Partial

; displayName?: string; } interface FunctionComponent

{ (props: P & { children?: {} }, context?: any): {} | null; propTypes?: WeakValidationMap

; defaultProps?: Partial

; displayName?: string; } declare const nominalTypeHack: unique symbol; interface Validator { ( props: object, propName: string, componentName: string, location: string, propFullName: string ): Error | null; [nominalTypeHack]?: T; } type WeakValidationMap = { [K in keyof T]?: null extends T[K] ? Validator : undefined extends T[K] ? Validator : Validator }; type ComponentType

= ComponentClass

| FunctionComponent

; type Shared< InjectedProps, DecorationTargetProps extends Shared > = { [P in Extract< keyof InjectedProps, keyof DecorationTargetProps >]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never }; // Infers prop type from component C type GetProps = C extends ComponentType ? P : never; type ConnectedComponentClass, P> = ComponentClass< P > & { WrappedComponent: C; }; type Matching = { [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P] }; type Omit = Pick>; type InferableComponentEnhancerWithProps = < C extends ComponentType>> >( component: C ) => ConnectedComponentClass< C, Omit, keyof Shared>> & TNeedsProps >; declare const connect: { ( mapStateToProps: null | undefined, mapDispatchToProps: TDispatchProps ): InferableComponentEnhancerWithProps< ResolveThunks, TOwnProps >; }; type InferThunkActionCreatorType< TActionCreator extends (...args: any[]) => any > = TActionCreator extends ( ...args: infer TParams ) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator; type HandleThunkActionCreator = TActionCreator extends ( ...args: any[] ) => any ? InferThunkActionCreatorType : TActionCreator; type ResolveThunks = TDispatchProps extends { [key: string]: any; } ? { [C in keyof TDispatchProps]: HandleThunkActionCreator } : TDispatchProps; interface Dispatch { (action: T): T; } interface Action { type: T; } interface AnyAction extends Action { [extraProps: string]: any; } const simpleAction = (payload: boolean) => ({ type: "SIMPLE_ACTION", payload }); const thunkAction = (param1: number, param2: string) => async ( dispatch: Dispatch, { foo }: OwnProps ) => { return foo; }; interface OwnProps { foo: string; } interface TestComponentProps extends OwnProps { simpleAction: typeof simpleAction; thunkAction(param1: number, param2: string): Promise; } class TestComponent extends Component {} const mapDispatchToProps = { simpleAction, thunkAction }; type Q = HandleThunkActionCreator; const Test1 = connect( null, mapDispatchToProps )(TestComponent); export {};