/** The order of type arguments for connect() is as follows: connect(…) In Flow v0.89 only the first two are mandatory to specify. Other 4 can be repaced with the new awesome type placeholder: connect(…) But beware, in case of weird type errors somewhere in random places just type everything and get to a green field and only then try to remove the definitions you see bogus. Decrypting the abbreviations: WC = Component being wrapped S = State D = Dispatch OP = OwnProps SP = StateProps DP = DispatchProps MP = Merge props RSP = Returned state props RDP = Returned dispatch props RMP = Returned merge props CP = Props for returned component Com = React Component ST = Static properties of Com EFO = Extra factory options (used only in connectAdvanced) */ declare module "react-redux" { // ------------------------------------------------------------ // Typings for connect() // ------------------------------------------------------------ declare export type Options = {| pure?: boolean, withRef?: boolean, areStatesEqual?: (next: S, prev: S) => boolean, areOwnPropsEqual?: (next: OP, prev: OP) => boolean, areStatePropsEqual?: (next: SP, prev: SP) => boolean, areMergedPropsEqual?: (next: MP, prev: MP) => boolean, storeKey?: string, |}; declare type MapStateToProps<-S, -OP, +SP> = | ((state: S, ownProps: OP) => SP) // If you want to use the factory function but get a strange error // like "function is not an object" then just type the factory function // like this: // const factory: (State, OwnProps) => (State, OwnProps) => StateProps // and provide the StateProps type to the SP type parameter. | ((state: S, ownProps: OP) => (state: S, ownProps: OP) => SP); declare type Bind = ((...A) => R) => (...A) => $Call; declare type MapDispatchToPropsFn = | ((dispatch: D, ownProps: OP) => DP) // If you want to use the factory function but get a strange error // like "function is not an object" then just type the factory function // like this: // const factory: (Dispatch, OwnProps) => (Dispatch, OwnProps) => DispatchProps // and provide the DispatchProps type to the DP type parameter. | ((dispatch: D, ownProps: OP) => (dispatch: D, ownProps: OP) => DP); declare class ConnectedComponent extends React$Component { static +WrappedComponent: WC; getWrappedInstance(): React$ElementRef; } declare type Connector = >( WC, ) => Class> & WC; // No `mergeProps` argument declare export function connect<-P, -OP, -SP, -DP, -S, -D>( mapStateToProps?: null | void, mapDispatchToProps?: null | void, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector; declare export function connect<-P, -OP, -SP, -DP, -S, -D>( // If you get error here try adding return type to your mapStateToProps function mapStateToProps: MapStateToProps, mapDispatchToProps?: null | void, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector; // In this case DP is an object of functions which has been bound to dispatch // by the given mapDispatchToProps function. declare export function connect<-P, -OP, -SP, -DP, S, D>( mapStateToProps: null | void, mapDispatchToProps: MapDispatchToPropsFn, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector; // In this case DP is an object of action creators not yet bound to dispatch, // this difference is not important in the vanila redux, // but in case of usage with redux-thunk, the return type may differ. declare export function connect<-P, -OP, -SP, -DP, S, D>( mapStateToProps: null | void, mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector> |}>; declare export function connect<-P, -OP, -SP, -DP, S, D>( // If you get error here try adding return type to your mapStateToProps function mapStateToProps: MapStateToProps, mapDispatchToProps: MapDispatchToPropsFn, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector; declare export function connect<-P, -OP, -SP, -DP, S, D>( // If you get error here try adding return type to your mapStateToProps function mapStateToProps: MapStateToProps, mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options, // Got error like inexact OwnProps is incompatible with exact object type? // Just make your OP parameter an exact object. ): Connector> |}>; // With `mergeProps` argument declare type MergeProps<+P, -OP, -SP, -DP> = ( stateProps: SP, dispatchProps: DP, ownProps: OP, ) => P; declare export function connect<-P, -OP, -SP: {||}, -DP: {||}, S, D>( mapStateToProps: null | void, mapDispatchToProps: null | void, // If you get error here try adding return type to you mapStateToProps function mergeProps: MergeProps, options?: ?Options, ): Connector; declare export function connect<-P, -OP, -SP, -DP: {||}, S, D>( mapStateToProps: MapStateToProps, mapDispatchToProps: null | void, // If you get error here try adding return type to you mapStateToProps function mergeProps: MergeProps, options?: ?Options, ): Connector; // In this case DP is an object of functions which has been bound to dispatch // by the given mapDispatchToProps function. declare export function connect<-P, -OP, -SP: {||}, -DP, S, D>( mapStateToProps: null | void, mapDispatchToProps: MapDispatchToPropsFn, mergeProps: MergeProps, options?: ?Options, ): Connector; // In this case DP is an object of action creators not yet bound to dispatch, // this difference is not important in the vanila redux, // but in case of usage with redux-thunk, the return type may differ. declare export function connect<-P, -OP, -SP: {||}, -DP, S, D>( mapStateToProps: null | void, mapDispatchToProps: DP, mergeProps: MergeProps>>, options?: ?Options, ): Connector; // In this case DP is an object of functions which has been bound to dispatch // by the given mapDispatchToProps function. declare export function connect<-P, -OP, -SP, -DP, S, D>( mapStateToProps: MapStateToProps, mapDispatchToProps: MapDispatchToPropsFn, mergeProps: MergeProps, options?: ?Options, ): Connector; // In this case DP is an object of action creators not yet bound to dispatch, // this difference is not important in the vanila redux, // but in case of usage with redux-thunk, the return type may differ. declare export function connect<-P, -OP, -SP, -DP, S, D>( mapStateToProps: MapStateToProps, mapDispatchToProps: DP, mergeProps: MergeProps>>, options?: ?Options, ): Connector; // ------------------------------------------------------------ // Typings for Provider // ------------------------------------------------------------ declare export class Provider extends React$Component<{ store: Store, children?: React$Node, }> {} declare export function createProvider( storeKey?: string, subKey?: string, ): Class>; // ------------------------------------------------------------ // Typings for connectAdvanced() // ------------------------------------------------------------ declare type ConnectAdvancedOptions = { getDisplayName?: (name: string) => string, methodName?: string, renderCountProp?: string, shouldHandleStateChanges?: boolean, storeKey?: string, withRef?: boolean, }; declare type SelectorFactoryOptions = { getDisplayName: (name: string) => string, methodName: string, renderCountProp: ?string, shouldHandleStateChanges: boolean, storeKey: string, withRef: boolean, displayName: string, wrappedComponentName: string, WrappedComponent: Com, }; declare type MapStateToPropsEx = ( state: S, props: SP, ) => RSP; declare type SelectorFactory< Com: React$ComponentType<*>, Dispatch, S: Object, OP: Object, EFO: Object, CP: Object, > = ( dispatch: Dispatch, factoryOptions: SelectorFactoryOptions & EFO, ) => MapStateToPropsEx; declare export function connectAdvanced< Com: React$ComponentType<*>, D, S: Object, OP: Object, CP: Object, EFO: Object, ST: { [_: $Keys]: any }, >( selectorFactory: SelectorFactory, connectAdvancedOptions: ?(ConnectAdvancedOptions & EFO), ): (component: Com) => React$ComponentType & $Shape; declare export default { Provider: typeof Provider, createProvider: typeof createProvider, connect: typeof connect, connectAdvanced: typeof connectAdvanced, }; }