|
@@ -1,132 +1,154 @@
|
1
|
|
-// flow-typed signature: 59b0c4be0e1408f21e2446be96c79804
|
2
|
|
-// flow-typed version: 9092387fd2/react-redux_v5.x.x/flow_>=v0.54.x
|
3
|
|
-
|
4
|
1
|
import type { Dispatch, Store } from "redux";
|
5
|
2
|
|
6
|
3
|
declare module "react-redux" {
|
7
|
|
- /*
|
8
|
|
-
|
9
|
|
- S = State
|
10
|
|
- A = Action
|
11
|
|
- OP = OwnProps
|
12
|
|
- SP = StateProps
|
13
|
|
- DP = DispatchProps
|
14
|
|
-
|
15
|
|
- */
|
|
4
|
+ import type { ComponentType, ElementConfig } from 'react';
|
16
|
5
|
|
17
|
|
- declare type MapStateToProps<S, OP: Object, SP: Object> = (
|
18
|
|
- state: S,
|
19
|
|
- ownProps: OP
|
20
|
|
- ) => ((state: S, ownProps: OP) => SP) | SP;
|
21
|
|
-
|
22
|
|
- declare type MapDispatchToProps<A, OP: Object, DP: Object> =
|
23
|
|
- | ((dispatch: Dispatch<A>, ownProps: OP) => DP)
|
24
|
|
- | DP;
|
25
|
|
-
|
26
|
|
- declare type MergeProps<SP, DP: Object, OP: Object, P: Object> = (
|
27
|
|
- stateProps: SP,
|
28
|
|
- dispatchProps: DP,
|
29
|
|
- ownProps: OP
|
30
|
|
- ) => P;
|
31
|
|
-
|
32
|
|
- declare type Context = { store: Store<*, *> };
|
33
|
|
-
|
34
|
|
- declare type ComponentWithDefaultProps<DP: {}, P: {}, CP: P> = Class<
|
35
|
|
- React$Component<CP>
|
36
|
|
- > & { defaultProps: DP };
|
37
|
|
-
|
38
|
|
- declare class ConnectedComponentWithDefaultProps<
|
39
|
|
- OP,
|
40
|
|
- DP,
|
41
|
|
- CP
|
42
|
|
- > extends React$Component<OP> {
|
43
|
|
- static defaultProps: DP, // <= workaround for https://github.com/facebook/flow/issues/4644
|
44
|
|
- static WrappedComponent: Class<React$Component<CP>>,
|
45
|
|
- getWrappedInstance(): React$Component<CP>,
|
46
|
|
- props: OP,
|
47
|
|
- state: void
|
48
|
|
- }
|
49
|
|
-
|
50
|
|
- declare class ConnectedComponent<OP, P> extends React$Component<OP> {
|
51
|
|
- static WrappedComponent: Class<React$Component<P>>,
|
52
|
|
- getWrappedInstance(): React$Component<P>,
|
53
|
|
- props: OP,
|
54
|
|
- state: void
|
55
|
|
- }
|
56
|
|
-
|
57
|
|
- declare type ConnectedComponentWithDefaultPropsClass<OP, DP, CP> = Class<
|
58
|
|
- ConnectedComponentWithDefaultProps<OP, DP, CP>
|
59
|
|
- >;
|
60
|
|
-
|
61
|
|
- declare type ConnectedComponentClass<OP, P> = Class<
|
62
|
|
- ConnectedComponent<OP, P>
|
63
|
|
- >;
|
64
|
|
-
|
65
|
|
- declare type Connector<OP, P> = (<DP: {}, CP: {}>(
|
66
|
|
- component: ComponentWithDefaultProps<DP, P, CP>
|
67
|
|
- ) => ConnectedComponentWithDefaultPropsClass<OP, DP, CP>) &
|
68
|
|
- ((component: React$ComponentType<P>) => ConnectedComponentClass<OP, P>);
|
69
|
|
-
|
70
|
|
- declare class Provider<S, A> extends React$Component<{
|
|
6
|
+ declare export class Provider<S, A> extends React$Component<{
|
71
|
7
|
store: Store<S, A>,
|
72
|
8
|
children?: any
|
73
|
9
|
}> {}
|
74
|
10
|
|
75
|
|
- declare function createProvider(
|
|
11
|
+ declare export function createProvider(
|
76
|
12
|
storeKey?: string,
|
77
|
13
|
subKey?: string
|
78
|
14
|
): Provider<*, *>;
|
79
|
15
|
|
80
|
|
- declare type ConnectOptions = {
|
|
16
|
+ /*
|
|
17
|
+
|
|
18
|
+ S = State
|
|
19
|
+ A = Action
|
|
20
|
+ OP = OwnProps
|
|
21
|
+ SP = StateProps
|
|
22
|
+ DP = DispatchProps
|
|
23
|
+ MP = Merge props
|
|
24
|
+ MDP = Map dispatch to props object
|
|
25
|
+ RSP = Returned state props
|
|
26
|
+ RDP = Returned dispatch props
|
|
27
|
+ RMP = Returned merge props
|
|
28
|
+ CP = Props for returned component
|
|
29
|
+ Com = React Component
|
|
30
|
+ */
|
|
31
|
+
|
|
32
|
+ declare type MapStateToProps<S: Object, SP: Object, RSP: Object> = (state: S, props: SP) => RSP;
|
|
33
|
+
|
|
34
|
+ declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP;
|
|
35
|
+
|
|
36
|
+ declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = (
|
|
37
|
+ stateProps: SP,
|
|
38
|
+ dispatchProps: DP,
|
|
39
|
+ ownProps: MP
|
|
40
|
+ ) => RMP;
|
|
41
|
+
|
|
42
|
+ declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {|
|
81
|
43
|
pure?: boolean,
|
82
|
|
- withRef?: boolean
|
|
44
|
+ withRef?: boolean,
|
|
45
|
+ areStatesEqual?: (next: S, prev: S) => boolean,
|
|
46
|
+ areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
|
|
47
|
+ areStatePropsEqual?: (next: RSP, prev: RSP) => boolean,
|
|
48
|
+ areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean,
|
|
49
|
+ storeKey?: string
|
|
50
|
+ |};
|
|
51
|
+
|
|
52
|
+ declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>;
|
|
53
|
+
|
|
54
|
+ declare export function connect<
|
|
55
|
+ Com: ComponentType<*>,
|
|
56
|
+ S: Object,
|
|
57
|
+ DP: Object,
|
|
58
|
+ RSP: Object,
|
|
59
|
+ CP: $Diff<OmitDispatch<ElementConfig<Com>>, RSP>
|
|
60
|
+ >(
|
|
61
|
+ mapStateToProps: MapStateToProps<S, DP, RSP>,
|
|
62
|
+ mapDispatchToProps?: null
|
|
63
|
+ ): (component: Com) => ComponentType<CP & DP>;
|
|
64
|
+
|
|
65
|
+ declare export function connect<Com: ComponentType<*>>(
|
|
66
|
+ mapStateToProps?: null,
|
|
67
|
+ mapDispatchToProps?: null
|
|
68
|
+ ): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>;
|
|
69
|
+
|
|
70
|
+ declare export function connect<
|
|
71
|
+ Com: ComponentType<*>,
|
|
72
|
+ A,
|
|
73
|
+ S: Object,
|
|
74
|
+ DP: Object,
|
|
75
|
+ SP: Object,
|
|
76
|
+ RSP: Object,
|
|
77
|
+ RDP: Object,
|
|
78
|
+ CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>
|
|
79
|
+ >(
|
|
80
|
+ mapStateToProps: MapStateToProps<S, SP, RSP>,
|
|
81
|
+ mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
|
|
82
|
+ ): (component: Com) => ComponentType<CP & SP & DP>;
|
|
83
|
+
|
|
84
|
+ declare export function connect<
|
|
85
|
+ Com: ComponentType<*>,
|
|
86
|
+ A,
|
|
87
|
+ OP: Object,
|
|
88
|
+ DP: Object,
|
|
89
|
+ PR: Object,
|
|
90
|
+ CP: $Diff<ElementConfig<Com>, DP>
|
|
91
|
+ >(
|
|
92
|
+ mapStateToProps?: null,
|
|
93
|
+ mapDispatchToProps: MapDispatchToProps<A, OP, DP>
|
|
94
|
+ ): (Com) => ComponentType<CP & OP>;
|
|
95
|
+
|
|
96
|
+ declare export function connect<
|
|
97
|
+ Com: ComponentType<*>,
|
|
98
|
+ MDP: Object
|
|
99
|
+ >(
|
|
100
|
+ mapStateToProps?: null,
|
|
101
|
+ mapDispatchToProps: MDP
|
|
102
|
+ ): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>;
|
|
103
|
+
|
|
104
|
+ declare export function connect<
|
|
105
|
+ Com: ComponentType<*>,
|
|
106
|
+ S: Object,
|
|
107
|
+ SP: Object,
|
|
108
|
+ RSP: Object,
|
|
109
|
+ MDP: Object,
|
|
110
|
+ CP: $Diff<ElementConfig<Com>, RSP>
|
|
111
|
+ >(
|
|
112
|
+ mapStateToProps: MapStateToProps<S, SP, RSP>,
|
|
113
|
+ mapDispatchToPRops: MDP
|
|
114
|
+ ): (component: Com) => ComponentType<$Diff<CP, MDP> & SP>;
|
|
115
|
+
|
|
116
|
+ declare export function connect<
|
|
117
|
+ Com: ComponentType<*>,
|
|
118
|
+ A,
|
|
119
|
+ S: Object,
|
|
120
|
+ DP: Object,
|
|
121
|
+ SP: Object,
|
|
122
|
+ RSP: Object,
|
|
123
|
+ RDP: Object,
|
|
124
|
+ MP: Object,
|
|
125
|
+ RMP: Object,
|
|
126
|
+ CP: $Diff<ElementConfig<Com>, RMP>
|
|
127
|
+ >(
|
|
128
|
+ mapStateToProps: MapStateToProps<S, SP, RSP>,
|
|
129
|
+ mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
|
|
130
|
+ mergeProps: MergeProps<RSP, RDP, MP, RMP>
|
|
131
|
+ ): (component: Com) => ComponentType<CP & SP & DP & MP>;
|
|
132
|
+
|
|
133
|
+ declare export function connect<Com: ComponentType<*>,
|
|
134
|
+ A,
|
|
135
|
+ S: Object,
|
|
136
|
+ DP: Object,
|
|
137
|
+ SP: Object,
|
|
138
|
+ RSP: Object,
|
|
139
|
+ RDP: Object,
|
|
140
|
+ MP: Object,
|
|
141
|
+ RMP: Object
|
|
142
|
+ >(
|
|
143
|
+ mapStateToProps: ?MapStateToProps<S, SP, RSP>,
|
|
144
|
+ mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
|
|
145
|
+ mergeProps: ?MergeProps<RSP, RDP, MP, RMP>,
|
|
146
|
+ options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
|
|
147
|
+ ): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
|
|
148
|
+
|
|
149
|
+ declare export default {
|
|
150
|
+ Provider: typeof Provider,
|
|
151
|
+ createProvider: typeof createProvider,
|
|
152
|
+ connect: typeof connect,
|
83
|
153
|
};
|
84
|
|
-
|
85
|
|
- declare type Null = null | void;
|
86
|
|
-
|
87
|
|
- declare function connect<A, OP>(
|
88
|
|
- ...rest: Array<void> // <= workaround for https://github.com/facebook/flow/issues/2360
|
89
|
|
- ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
|
90
|
|
-
|
91
|
|
- declare function connect<A, OP>(
|
92
|
|
- mapStateToProps: Null,
|
93
|
|
- mapDispatchToProps: Null,
|
94
|
|
- mergeProps: Null,
|
95
|
|
- options: ConnectOptions
|
96
|
|
- ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
|
97
|
|
-
|
98
|
|
-// declare function connect<S, A, OP, SP>(
|
99
|
|
-// mapStateToProps: MapStateToProps<S, OP, SP>,
|
100
|
|
-// mapDispatchToProps: Null,
|
101
|
|
-// mergeProps: Null,
|
102
|
|
-// options?: ConnectOptions
|
103
|
|
-// ): Connector<OP, $Supertype<SP & { dispatch: Dispatch<A> } & OP>>;
|
104
|
|
-
|
105
|
|
- declare function connect<A, OP, DP>(
|
106
|
|
- mapStateToProps: Null,
|
107
|
|
- mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
|
108
|
|
- mergeProps: Null,
|
109
|
|
- options?: ConnectOptions
|
110
|
|
- ): Connector<OP, $Supertype<DP & OP>>;
|
111
|
|
-
|
112
|
|
- declare function connect<S, A, OP, SP, DP>(
|
113
|
|
- mapStateToProps: MapStateToProps<S, OP, SP>,
|
114
|
|
- mapDispatchToProps: MapDispatchToProps<A, OP, DP> | Null,
|
115
|
|
- mergeProps: Null,
|
116
|
|
- options?: ConnectOptions
|
117
|
|
- ): Connector<OP, $Supertype<SP & DP & OP>>;
|
118
|
|
-
|
119
|
|
- declare function connect<S, A, OP, SP, DP, P>(
|
120
|
|
- mapStateToProps: MapStateToProps<S, OP, SP>,
|
121
|
|
- mapDispatchToProps: Null,
|
122
|
|
- mergeProps: MergeProps<SP, DP, OP, P>,
|
123
|
|
- options?: ConnectOptions
|
124
|
|
- ): Connector<OP, P>;
|
125
|
|
-
|
126
|
|
- declare function connect<S, A, OP, SP, DP, P>(
|
127
|
|
- mapStateToProps: MapStateToProps<S, OP, SP>,
|
128
|
|
- mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
|
129
|
|
- mergeProps: MergeProps<SP, DP, OP, P>,
|
130
|
|
- options?: ConnectOptions
|
131
|
|
- ): Connector<OP, P>;
|
132
|
154
|
}
|