|
| 1 | +// flow-typed signature: 3d2adf9e3c8823252a60ff4631b486a3 |
| 2 | +// flow-typed version: 844b6ca3d3/react-redux_v5.x.x/flow_>=v0.63.0 |
| 3 | + |
| 4 | +import type { Dis, Store } from "redux"; |
| 5 | + |
| 6 | +declare module "react-redux" { |
| 7 | +import type { ComponentType, ElementConfig } from 'react'; |
| 8 | + |
| 9 | +declare export class Provider<S, A> extends React$Component<{ |
| 10 | +store: Store<S, A>, |
| 11 | +children?: any |
| 12 | +}> {} |
| 13 | + |
| 14 | +declare export function createProvider( |
| 15 | +storeKey?: string, |
| 16 | +subKey?: string |
| 17 | +): Provider<*, *>; |
| 18 | + |
| 19 | +/* |
| 20 | +
|
| 21 | +S = State |
| 22 | +A = Action |
| 23 | +OP = OwnProps |
| 24 | +SP = StateProps |
| 25 | +DP = DisProps |
| 26 | +MP = Merge props |
| 27 | +MDP = Map dis to props object |
| 28 | +RSP = Returned state props |
| 29 | +RDP = Returned dis props |
| 30 | +RMP = Returned merge props |
| 31 | +CP = Props for returned component |
| 32 | +Com = React Component |
| 33 | +ST = Static properties of Com |
| 34 | +*/ |
| 35 | + |
| 36 | +declare type MapStateToProps<S: Object, SP: Object, RSP: Object> = (state: S, props: SP) => RSP; |
| 37 | + |
| 38 | +declare type MapDisToProps<A, OP: Object, RDP: Object> = (dis: Dis<A>, ownProps: OP) => RDP; |
| 39 | + |
| 40 | +declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = ( |
| 41 | +stateProps: SP, |
| 42 | +disProps: DP, |
| 43 | +ownProps: MP |
| 44 | +) => RMP; |
| 45 | + |
| 46 | +declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {| |
| 47 | +pure?: boolean, |
| 48 | +withRef?: boolean, |
| 49 | +areStatesEqual?: (next: S, prev: S) => boolean, |
| 50 | +areOwnPropsEqual?: (next: OP, prev: OP) => boolean, |
| 51 | +areStatePropsEqual?: (next: RSP, prev: RSP) => boolean, |
| 52 | +areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean, |
| 53 | +storeKey?: string |
| 54 | +|}; |
| 55 | + |
| 56 | +declare type OmitDis<Component> = $Diff<Component, {dis: Dis<*>}>; |
| 57 | + |
| 58 | +declare export function connect< |
| 59 | +Com: ComponentType<*>, |
| 60 | +S: Object, |
| 61 | +SP: Object, |
| 62 | +RSP: Object, |
| 63 | +CP: $Diff<OmitDis<ElementConfig<Com>>, RSP>, |
| 64 | +ST: {[_: $Keys<Com>]: any} |
| 65 | +>( |
| 66 | +mapStateToProps: MapStateToProps<S, SP, RSP>, |
| 67 | +mapDisToProps?: null |
| 68 | +): (component: Com) => ComponentType<CP & SP> & $Shape<ST>; |
| 69 | + |
| 70 | +declare export function connect< |
| 71 | +Com: ComponentType<*>, |
| 72 | +ST: {[_: $Keys<Com>]: any} |
| 73 | +>( |
| 74 | +mapStateToProps?: null, |
| 75 | +mapDisToProps?: null |
| 76 | +): (component: Com) => ComponentType<OmitDis<ElementConfig<Com>>> & $Shape<ST>; |
| 77 | + |
| 78 | +declare export function connect< |
| 79 | +Com: ComponentType<*>, |
| 80 | +A, |
| 81 | +S: Object, |
| 82 | +DP: Object, |
| 83 | +SP: Object, |
| 84 | +RSP: Object, |
| 85 | +RDP: Object, |
| 86 | +CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>, |
| 87 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 88 | +>( |
| 89 | +mapStateToProps: MapStateToProps<S, SP, RSP>, |
| 90 | +mapDisToProps: MapDisToProps<A, DP, RDP> |
| 91 | +): (component: Com) => ComponentType<CP & SP & DP> & $Shape<ST>; |
| 92 | + |
| 93 | +declare export function connect< |
| 94 | +Com: ComponentType<*>, |
| 95 | +A, |
| 96 | +OP: Object, |
| 97 | +DP: Object, |
| 98 | +PR: Object, |
| 99 | +CP: $Diff<ElementConfig<Com>, DP>, |
| 100 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 101 | +>( |
| 102 | +mapStateToProps?: null, |
| 103 | +mapDisToProps: MapDisToProps<A, OP, DP> |
| 104 | +): (Com) => ComponentType<CP & OP>; |
| 105 | + |
| 106 | +declare export function connect< |
| 107 | +Com: ComponentType<*>, |
| 108 | +MDP: Object, |
| 109 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 110 | +>( |
| 111 | +mapStateToProps?: null, |
| 112 | +mapDisToProps: MDP |
| 113 | +): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>> & $Shape<ST>; |
| 114 | + |
| 115 | +declare export function connect< |
| 116 | +Com: ComponentType<*>, |
| 117 | +S: Object, |
| 118 | +SP: Object, |
| 119 | +RSP: Object, |
| 120 | +MDP: Object, |
| 121 | +CP: $Diff<ElementConfig<Com>, RSP>, |
| 122 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 123 | +>( |
| 124 | +mapStateToProps: MapStateToProps<S, SP, RSP>, |
| 125 | +mapDisToProps: MDP |
| 126 | +): (component: Com) => ComponentType<$Diff<CP, MDP> & SP> & $Shape<ST>; |
| 127 | + |
| 128 | +declare export function connect< |
| 129 | +Com: ComponentType<*>, |
| 130 | +A, |
| 131 | +S: Object, |
| 132 | +DP: Object, |
| 133 | +SP: Object, |
| 134 | +RSP: Object, |
| 135 | +RDP: Object, |
| 136 | +MP: Object, |
| 137 | +RMP: Object, |
| 138 | +CP: $Diff<ElementConfig<Com>, RMP>, |
| 139 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 140 | +>( |
| 141 | +mapStateToProps: MapStateToProps<S, SP, RSP>, |
| 142 | +mapDisToProps: ?MapDisToProps<A, DP, RDP>, |
| 143 | +mergeProps: MergeProps<RSP, RDP, MP, RMP> |
| 144 | +): (component: Com) => ComponentType<CP & SP & DP & MP> & $Shape<ST>; |
| 145 | + |
| 146 | +declare export function connect< |
| 147 | +Com: ComponentType<*>, |
| 148 | +A, |
| 149 | +S: Object, |
| 150 | +DP: Object, |
| 151 | +SP: Object, |
| 152 | +RSP: Object, |
| 153 | +RDP: Object, |
| 154 | +MDP: Object, |
| 155 | +MP: Object, |
| 156 | +RMP: Object, |
| 157 | +CP: $Diff<ElementConfig<Com>, RMP>, |
| 158 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 159 | +>( |
| 160 | +mapStateToProps: MapStateToProps<S, SP, RSP>, |
| 161 | +mapDisToProps: MDP, |
| 162 | +mergeProps: MergeProps<RSP, RDP, MP, RMP> |
| 163 | +): (component: Com) => ComponentType<CP & SP & DP & MP> & $Shape<ST>; |
| 164 | + |
| 165 | +declare export function connect<Com: ComponentType<*>, |
| 166 | +A, |
| 167 | +S: Object, |
| 168 | +DP: Object, |
| 169 | +SP: Object, |
| 170 | +RSP: Object, |
| 171 | +RDP: Object, |
| 172 | +MP: Object, |
| 173 | +RMP: Object, |
| 174 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 175 | +>( |
| 176 | +mapStateToProps: ?MapStateToProps<S, SP, RSP>, |
| 177 | +mapDisToProps: ?MapDisToProps<A, DP, RDP>, |
| 178 | +mergeProps: ?MergeProps<RSP, RDP, MP, RMP>, |
| 179 | +options: ConnectOptions<S, SP & DP & MP, RSP, RMP> |
| 180 | +): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP> & $Shape<ST>; |
| 181 | + |
| 182 | +declare export function connect<Com: ComponentType<*>, |
| 183 | +A, |
| 184 | +S: Object, |
| 185 | +DP: Object, |
| 186 | +SP: Object, |
| 187 | +RSP: Object, |
| 188 | +RDP: Object, |
| 189 | +MDP: Object, |
| 190 | +MP: Object, |
| 191 | +RMP: Object, |
| 192 | +ST: $Subtype<{[_: $Keys<Com>]: any}> |
| 193 | +>( |
| 194 | +mapStateToProps: ?MapStateToProps<S, SP, RSP>, |
| 195 | +mapDisToProps: ?MapDisToProps<A, DP, RDP>, |
| 196 | +mergeProps: MDP, |
| 197 | +options: ConnectOptions<S, SP & DP & MP, RSP, RMP> |
| 198 | +): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP> & $Shape<ST>; |
| 199 | + |
| 200 | +declare export default { |
| 201 | +Provider: typeof Provider, |
| 202 | +createProvider: typeof createProvider, |
| 203 | +connect: typeof connect, |
| 204 | +}; |
| 205 | +} |
0 commit comments