Browse Source

flow: update type definitions

master
Saúl Ibarra Corretgé 6 years ago
parent
commit
278d3a163b

+ 23
- 16
flow-typed/npm/jquery_v3.x.x.js View File

@@ -1,5 +1,5 @@
1
-// flow-typed signature: d71d314ca25fc6c20610a3ba80af9df0
2
-// flow-typed version: 9698a46399/jquery_v3.x.x/flow_>=v0.28.x
1
+// flow-typed signature: f26fda66e3a551aef37d3b0f53058e6a
2
+// flow-typed version: 44ad941b7a/jquery_v3.x.x/flow_>=v0.28.x
3 3
 
4 4
 /* eslint-disable max-len, no-unused-vars, flowtype/no-weak-types */
5 5
 
@@ -364,6 +364,13 @@ declare class JQueryGenericPromise<T> {
364 364
     failFilter?: (...reasons: any[]) => any,
365 365
     progressFilter?: (...progression: any[]) => any
366 366
   ): JQueryPromise<void>;
367
+
368
+  /**
369
+   * Add handlers to be called when the Deferred object is rejected.
370
+   *
371
+   * @param  failFilter An function that is called when the Deferred is rejected.
372
+   */
373
+  catch(failFilter: (...reasons: any[]) => any): JQueryPromise<T>;
367 374
 }
368 375
 
369 376
 /**
@@ -822,7 +829,7 @@ declare class JQueryStatic {
822 829
    */
823 830
   get(
824 831
     url: string,
825
-    data?: Object | string,
832
+    data?: {} | string,
826 833
     success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
827 834
     dataType?: string
828 835
   ): JQueryXHR;
@@ -845,7 +852,7 @@ declare class JQueryStatic {
845 852
    */
846 853
   getJSON(
847 854
     url: string,
848
-    data?: Object | string,
855
+    data?: {} | string,
849 856
     success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any
850 857
   ): JQueryXHR;
851 858
   /**
@@ -886,7 +893,7 @@ declare class JQueryStatic {
886 893
    */
887 894
   post(
888 895
     url: string,
889
-    data?: Object | string,
896
+    data?: {} | string,
890 897
     success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
891 898
     dataType?: string
892 899
   ): JQueryXHR;
@@ -967,7 +974,7 @@ declare class JQueryStatic {
967 974
    * @param html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
968 975
    * @param attributes An object of attributes, events, and methods to call on the newly-created element.
969 976
    */
970
-  (html: string, attributes: Object): JQuery;
977
+  (html: string, attributes: {}): JQuery;
971 978
 
972 979
   /**
973 980
    * Relinquish jQuery's control of the $ variable.
@@ -1425,7 +1432,7 @@ declare class JQuery {
1425 1432
    */
1426 1433
   load(
1427 1434
     url: string,
1428
-    data?: string | Object,
1435
+    data?: string | {},
1429 1436
     complete?: (
1430 1437
       responseText: string,
1431 1438
       textStatus: string,
@@ -1482,7 +1489,7 @@ declare class JQuery {
1482 1489
    *
1483 1490
    * @param attributes An object of attribute-value pairs to set.
1484 1491
    */
1485
-  attr(attributes: Object): JQuery;
1492
+  attr(attributes: {}): JQuery;
1486 1493
   /**
1487 1494
    * Get the value of an attribute for the first element in the set of matched elements.
1488 1495
    *
@@ -1532,7 +1539,7 @@ declare class JQuery {
1532 1539
    *
1533 1540
    * @param properties An object of property-value pairs to set.
1534 1541
    */
1535
-  prop(properties: Object): JQuery;
1542
+  prop(properties: {}): JQuery;
1536 1543
   /**
1537 1544
    * Set one or more properties for the set of matched elements.
1538 1545
    *
@@ -1598,7 +1605,7 @@ declare class JQuery {
1598 1605
   /**
1599 1606
    * Get the current value of the first element in the set of matched elements.
1600 1607
    */
1601
-  val(_: void): any;
1608
+  val(_: void): string | string[] | number;
1602 1609
   /**
1603 1610
    * Set the value of each element in the set of matched elements.
1604 1611
    *
@@ -1634,7 +1641,7 @@ declare class JQuery {
1634 1641
    *
1635 1642
    * @param properties An object of property-value pairs to set.
1636 1643
    */
1637
-  css(properties: Object): JQuery;
1644
+  css(properties: {}): JQuery;
1638 1645
   /**
1639 1646
    * Get the value of style properties for the first element in the set of matched elements.
1640 1647
    *
@@ -1847,7 +1854,7 @@ declare class JQuery {
1847 1854
    * @param complete A function to call once the animation is complete.
1848 1855
    */
1849 1856
   animate(
1850
-    properties: Object,
1857
+    properties: {},
1851 1858
     duration?: string | number,
1852 1859
     complete?: Function
1853 1860
   ): JQuery;
@@ -1860,7 +1867,7 @@ declare class JQuery {
1860 1867
    * @param complete A function to call once the animation is complete.
1861 1868
    */
1862 1869
   animate(
1863
-    properties: Object,
1870
+    properties: {},
1864 1871
     duration?: string | number,
1865 1872
     easing?: string,
1866 1873
     complete?: Function
@@ -1871,7 +1878,7 @@ declare class JQuery {
1871 1878
    * @param properties An object of CSS properties and values that the animation will move toward.
1872 1879
    * @param options A map of additional options to pass to the method.
1873 1880
    */
1874
-  animate(properties: Object, options: JQueryAnimationOptions): JQuery;
1881
+  animate(properties: {}, options: JQueryAnimationOptions): JQuery;
1875 1882
 
1876 1883
   /**
1877 1884
    * Set a timer to delay execution of subsequent items in the queue.
@@ -2920,14 +2927,14 @@ declare class JQuery {
2920 2927
    * @param eventType A string containing a JavaScript event type, such as click or submit.
2921 2928
    * @param extraParameters Additional parameters to pass along to the event handler.
2922 2929
    */
2923
-  trigger(eventType: string, extraParameters?: any[] | Object): JQuery;
2930
+  trigger(eventType: string, extraParameters?: any[] | {}): JQuery;
2924 2931
   /**
2925 2932
    * Execute all handlers and behaviors attached to the matched elements for the given event type.
2926 2933
    *
2927 2934
    * @param event A jQuery.Event object.
2928 2935
    * @param extraParameters Additional parameters to pass along to the event handler.
2929 2936
    */
2930
-  trigger(event: JQueryEventObject, extraParameters?: any[] | Object): JQuery;
2937
+  trigger(event: JQueryEventObject, extraParameters?: any[] | {}): JQuery;
2931 2938
 
2932 2939
   /**
2933 2940
    * Execute all handlers attached to an element for an event.

+ 460
- 369
flow-typed/npm/lodash_v4.x.x.js
File diff suppressed because it is too large
View File


+ 0
- 329
flow-typed/npm/moment_v2.3.x.js View File

@@ -1,329 +0,0 @@
1
-// flow-typed signature: c30aa20539f52183d4d30dd36d8ab9c2
2
-// flow-typed version: 886cf7c002/moment_v2.3.x/flow_>=v0.63.x
3
-
4
-type moment$MomentOptions = {
5
-  y?: number | string,
6
-  year?: number | string,
7
-  years?: number | string,
8
-  M?: number | string,
9
-  month?: number | string,
10
-  months?: number | string,
11
-  d?: number | string,
12
-  day?: number | string,
13
-  days?: number | string,
14
-  date?: number | string,
15
-  h?: number | string,
16
-  hour?: number | string,
17
-  hours?: number | string,
18
-  m?: number | string,
19
-  minute?: number | string,
20
-  minutes?: number | string,
21
-  s?: number | string,
22
-  second?: number | string,
23
-  seconds?: number | string,
24
-  ms?: number | string,
25
-  millisecond?: number | string,
26
-  milliseconds?: number | string
27
-};
28
-
29
-type moment$MomentObject = {
30
-  years: number,
31
-  months: number,
32
-  date: number,
33
-  hours: number,
34
-  minutes: number,
35
-  seconds: number,
36
-  milliseconds: number
37
-};
38
-
39
-type moment$MomentCreationData = {
40
-  input: string,
41
-  format: string,
42
-  locale: Object,
43
-  isUTC: boolean,
44
-  strict: boolean
45
-};
46
-
47
-type moment$CalendarFormat = string | ((moment: moment$Moment) => string);
48
-
49
-type moment$CalendarFormats = {
50
-  sameDay?: moment$CalendarFormat,
51
-  nextDay?: moment$CalendarFormat,
52
-  nextWeek?: moment$CalendarFormat,
53
-  lastDay?: moment$CalendarFormat,
54
-  lastWeek?: moment$CalendarFormat,
55
-  sameElse?: moment$CalendarFormat
56
-};
57
-
58
-declare class moment$LocaleData {
59
-  months(moment: moment$Moment): string,
60
-  monthsShort(moment: moment$Moment): string,
61
-  monthsParse(month: string): number,
62
-  weekdays(moment: moment$Moment): string,
63
-  weekdaysShort(moment: moment$Moment): string,
64
-  weekdaysMin(moment: moment$Moment): string,
65
-  weekdaysParse(weekDay: string): number,
66
-  longDateFormat(dateFormat: string): string,
67
-  isPM(date: string): boolean,
68
-  meridiem(hours: number, minutes: number, isLower: boolean): string,
69
-  calendar(
70
-    key:
71
-      | "sameDay"
72
-      | "nextDay"
73
-      | "lastDay"
74
-      | "nextWeek"
75
-      | "prevWeek"
76
-      | "sameElse",
77
-    moment: moment$Moment
78
-  ): string,
79
-  relativeTime(
80
-    number: number,
81
-    withoutSuffix: boolean,
82
-    key: "s" | "m" | "mm" | "h" | "hh" | "d" | "dd" | "M" | "MM" | "y" | "yy",
83
-    isFuture: boolean
84
-  ): string,
85
-  pastFuture(diff: any, relTime: string): string,
86
-  ordinal(number: number): string,
87
-  preparse(str: string): any,
88
-  postformat(str: string): any,
89
-  week(moment: moment$Moment): string,
90
-  invalidDate(): string,
91
-  firstDayOfWeek(): number,
92
-  firstDayOfYear(): number
93
-}
94
-declare class moment$MomentDuration {
95
-  humanize(suffix?: boolean): string,
96
-  milliseconds(): number,
97
-  asMilliseconds(): number,
98
-  seconds(): number,
99
-  asSeconds(): number,
100
-  minutes(): number,
101
-  asMinutes(): number,
102
-  hours(): number,
103
-  asHours(): number,
104
-  days(): number,
105
-  asDays(): number,
106
-  months(): number,
107
-  asMonths(): number,
108
-  years(): number,
109
-  asYears(): number,
110
-  add(value: number | moment$MomentDuration | Object, unit?: string): this,
111
-  subtract(value: number | moment$MomentDuration | Object, unit?: string): this,
112
-  as(unit: string): number,
113
-  get(unit: string): number,
114
-  toJSON(): string,
115
-  toISOString(): string,
116
-  isValid(): boolean
117
-}
118
-declare class moment$Moment {
119
-  static ISO_8601: string,
120
-  static (
121
-    string?: string,
122
-    format?: string | Array<string>,
123
-    strict?: boolean
124
-  ): moment$Moment,
125
-  static (
126
-    string?: string,
127
-    format?: string | Array<string>,
128
-    locale?: string,
129
-    strict?: boolean
130
-  ): moment$Moment,
131
-  static (
132
-    initDate: ?Object | number | Date | Array<number> | moment$Moment | string
133
-  ): moment$Moment,
134
-  static unix(seconds: number): moment$Moment,
135
-  static utc(): moment$Moment,
136
-  static utc(number: number | Array<number>): moment$Moment,
137
-  static utc(
138
-    str: string,
139
-    str2?: string | Array<string>,
140
-    str3?: string
141
-  ): moment$Moment,
142
-  static utc(moment: moment$Moment): moment$Moment,
143
-  static utc(date: Date): moment$Moment,
144
-  static parseZone(): moment$Moment,
145
-  static parseZone(rawDate: string): moment$Moment,
146
-  static parseZone(
147
-    rawDate: string,
148
-    format: string | Array<string>
149
-  ): moment$Moment,
150
-  static parseZone(
151
-    rawDate: string,
152
-    format: string,
153
-    strict: boolean
154
-  ): moment$Moment,
155
-  static parseZone(
156
-    rawDate: string,
157
-    format: string,
158
-    locale: string,
159
-    strict: boolean
160
-  ): moment$Moment,
161
-  isValid(): boolean,
162
-  invalidAt(): 0 | 1 | 2 | 3 | 4 | 5 | 6,
163
-  creationData(): moment$MomentCreationData,
164
-  millisecond(number: number): this,
165
-  milliseconds(number: number): this,
166
-  millisecond(): number,
167
-  milliseconds(): number,
168
-  second(number: number): this,
169
-  seconds(number: number): this,
170
-  second(): number,
171
-  seconds(): number,
172
-  minute(number: number): this,
173
-  minutes(number: number): this,
174
-  minute(): number,
175
-  minutes(): number,
176
-  hour(number: number): this,
177
-  hours(number: number): this,
178
-  hour(): number,
179
-  hours(): number,
180
-  date(number: number): this,
181
-  dates(number: number): this,
182
-  date(): number,
183
-  dates(): number,
184
-  day(day: number | string): this,
185
-  days(day: number | string): this,
186
-  day(): number,
187
-  days(): number,
188
-  weekday(number: number): this,
189
-  weekday(): number,
190
-  isoWeekday(number: number): this,
191
-  isoWeekday(): number,
192
-  dayOfYear(number: number): this,
193
-  dayOfYear(): number,
194
-  week(number: number): this,
195
-  weeks(number: number): this,
196
-  week(): number,
197
-  weeks(): number,
198
-  isoWeek(number: number): this,
199
-  isoWeeks(number: number): this,
200
-  isoWeek(): number,
201
-  isoWeeks(): number,
202
-  month(number: number): this,
203
-  months(number: number): this,
204
-  month(): number,
205
-  months(): number,
206
-  quarter(number: number): this,
207
-  quarter(): number,
208
-  year(number: number): this,
209
-  years(number: number): this,
210
-  year(): number,
211
-  years(): number,
212
-  weekYear(number: number): this,
213
-  weekYear(): number,
214
-  isoWeekYear(number: number): this,
215
-  isoWeekYear(): number,
216
-  weeksInYear(): number,
217
-  isoWeeksInYear(): number,
218
-  get(string: string): number,
219
-  set(unit: string, value: number): this,
220
-  set(options: { [unit: string]: number }): this,
221
-  static max(...dates: Array<moment$Moment>): moment$Moment,
222
-  static max(dates: Array<moment$Moment>): moment$Moment,
223
-  static min(...dates: Array<moment$Moment>): moment$Moment,
224
-  static min(dates: Array<moment$Moment>): moment$Moment,
225
-  add(
226
-    value: number | moment$MomentDuration | moment$Moment | Object,
227
-    unit?: string
228
-  ): this,
229
-  subtract(
230
-    value: number | moment$MomentDuration | moment$Moment | string | Object,
231
-    unit?: string
232
-  ): this,
233
-  startOf(unit: string): this,
234
-  endOf(unit: string): this,
235
-  local(): this,
236
-  utc(): this,
237
-  utcOffset(
238
-    offset: number | string,
239
-    keepLocalTime?: boolean,
240
-    keepMinutes?: boolean
241
-  ): this,
242
-  utcOffset(): number,
243
-  format(format?: string): string,
244
-  fromNow(removeSuffix?: boolean): string,
245
-  from(
246
-    value: moment$Moment | string | number | Date | Array<number>,
247
-    removePrefix?: boolean
248
-  ): string,
249
-  toNow(removePrefix?: boolean): string,
250
-  to(
251
-    value: moment$Moment | string | number | Date | Array<number>,
252
-    removePrefix?: boolean
253
-  ): string,
254
-  calendar(refTime?: any, formats?: moment$CalendarFormats): string,
255
-  diff(
256
-    date: moment$Moment | string | number | Date | Array<number>,
257
-    format?: string,
258
-    floating?: boolean
259
-  ): number,
260
-  valueOf(): number,
261
-  unix(): number,
262
-  daysInMonth(): number,
263
-  toDate(): Date,
264
-  toArray(): Array<number>,
265
-  toJSON(): string,
266
-  toISOString(
267
-    keepOffset?: boolean
268
-  ): string,
269
-  toObject(): moment$MomentObject,
270
-  isBefore(
271
-    date?: moment$Moment | string | number | Date | Array<number>,
272
-    units?: ?string
273
-  ): boolean,
274
-  isSame(
275
-    date?: moment$Moment | string | number | Date | Array<number>,
276
-    units?: ?string
277
-  ): boolean,
278
-  isAfter(
279
-    date?: moment$Moment | string | number | Date | Array<number>,
280
-    units?: ?string
281
-  ): boolean,
282
-  isSameOrBefore(
283
-    date?: moment$Moment | string | number | Date | Array<number>,
284
-    units?: ?string
285
-  ): boolean,
286
-  isSameOrAfter(
287
-    date?: moment$Moment | string | number | Date | Array<number>,
288
-    units?: ?string
289
-  ): boolean,
290
-  isBetween(
291
-    fromDate: moment$Moment | string | number | Date | Array<number>,
292
-    toDate?: ?moment$Moment | string | number | Date | Array<number>,
293
-    granularity?: ?string,
294
-    inclusion?: ?string
295
-  ): boolean,
296
-  isDST(): boolean,
297
-  isDSTShifted(): boolean,
298
-  isLeapYear(): boolean,
299
-  clone(): moment$Moment,
300
-  static isMoment(obj: any): boolean,
301
-  static isDate(obj: any): boolean,
302
-  static locale(locale: string, localeData?: Object): string,
303
-  static updateLocale(locale: string, localeData?: ?Object): void,
304
-  static locale(locales: Array<string>): string,
305
-  locale(locale: string, customization?: Object | null): moment$Moment,
306
-  locale(): string,
307
-  static months(): Array<string>,
308
-  static monthsShort(): Array<string>,
309
-  static weekdays(): Array<string>,
310
-  static weekdaysShort(): Array<string>,
311
-  static weekdaysMin(): Array<string>,
312
-  static months(): string,
313
-  static monthsShort(): string,
314
-  static weekdays(): string,
315
-  static weekdaysShort(): string,
316
-  static weekdaysMin(): string,
317
-  static localeData(key?: string): moment$LocaleData,
318
-  static duration(
319
-    value: number | Object | string,
320
-    unit?: string
321
-  ): moment$MomentDuration,
322
-  static isDuration(obj: any): boolean,
323
-  static normalizeUnits(unit: string): string,
324
-  static invalid(object: any): moment$Moment
325
-}
326
-
327
-declare module "moment" {
328
-  declare module.exports: Class<moment$Moment>;
329
-}

+ 241
- 157
flow-typed/npm/react-redux_v5.x.x.js View File

@@ -1,192 +1,276 @@
1
-// flow-typed signature: d4e793bc07ef1dc9906a244b12960f7b
2
-// flow-typed version: cf33ff8762/react-redux_v5.x.x/flow_>=v0.63.0
1
+// flow-typed signature: f06f00c3ad0cfedb90c0c6de04b219f3
2
+// flow-typed version: 3a6d556e4b/react-redux_v5.x.x/flow_>=v0.89.x
3 3
 
4
-import type { Dispatch, Store } from "redux";
4
+/**
5
+The order of type arguments for connect() is as follows:
5 6
 
6
-declare module "react-redux" {
7
-  import type { ComponentType, ElementConfig } from 'react';
7
+connect<Props, OwnProps, StateProps, DispatchProps, State, Dispatch>(…)
8 8
 
9
-  declare export class Provider<S, A> extends React$Component<{
10
-    store: Store<S, A>,
11
-    children?: any
12
-  }> {}
9
+In Flow v0.89 only the first two are mandatory to specify. Other 4 can be repaced with the new awesome type placeholder:
13 10
 
14
-  declare export function createProvider(
15
-    storeKey?: string,
16
-    subKey?: string
17
-  ): Provider<*, *>;
11
+connect<Props, OwnProps, _, _, _, _>(…)
18 12
 
19
-  /*
13
+But beware, in case of weird type errors somewhere in random places
14
+just type everything and get to a green field and only then try to
15
+remove the definitions you see bogus.
20 16
 
17
+Decrypting the abbreviations:
18
+  WC = Component being wrapped
21 19
   S = State
22
-  A = Action
20
+  D = Dispatch
23 21
   OP = OwnProps
24 22
   SP = StateProps
25 23
   DP = DispatchProps
26 24
   MP = Merge props
27
-  MDP = Map dispatch to props object
28 25
   RSP = Returned state props
29 26
   RDP = Returned dispatch props
30 27
   RMP = Returned merge props
31 28
   CP = Props for returned component
32 29
   Com = React Component
33
-  */
30
+  ST = Static properties of Com
31
+  EFO = Extra factory options (used only in connectAdvanced)
32
+*/
34 33
 
35
-  declare type MapStateToProps<S: Object, SP: Object, RSP: Object> = (state: S, props: SP) => RSP;
36
-
37
-  declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP;
38
-
39
-  declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = (
40
-    stateProps: SP,
41
-    dispatchProps: DP,
42
-    ownProps: MP
43
-  ) => RMP;
34
+declare module "react-redux" {
35
+  // ------------------------------------------------------------
36
+  // Typings for connect()
37
+  // ------------------------------------------------------------
44 38
 
45
-  declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {|
39
+  declare export type Options<S, OP, SP, MP> = {|
46 40
     pure?: boolean,
47 41
     withRef?: boolean,
48 42
     areStatesEqual?: (next: S, prev: S) => boolean,
49 43
     areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
50
-    areStatePropsEqual?: (next: RSP, prev: RSP) => boolean,
51
-    areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean,
52
-    storeKey?: string
44
+    areStatePropsEqual?: (next: SP, prev: SP) => boolean,
45
+    areMergedPropsEqual?: (next: MP, prev: MP) => boolean,
46
+    storeKey?: string,
53 47
   |};
54 48
 
55
-  declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>;
49
+  declare type MapStateToProps<-S, -OP, +SP> =
50
+    | ((state: S, ownProps: OP) => SP)
51
+    // If you want to use the factory function but get a strange error
52
+    // like "function is not an object" then just type the factory function
53
+    // like this:
54
+    // const factory: (State, OwnProps) => (State, OwnProps) => StateProps
55
+    // and provide the StateProps type to the SP type parameter.
56
+    | ((state: S, ownProps: OP) => (state: S, ownProps: OP) => SP);
56 57
 
57
-  declare export function connect<
58
-    Com: ComponentType<*>,
59
-    S: Object,
60
-    DP: Object,
61
-    RSP: Object,
62
-    CP: $Diff<OmitDispatch<ElementConfig<Com>>, RSP>
63
-    >(
64
-    mapStateToProps: MapStateToProps<S, DP, RSP>,
65
-    mapDispatchToProps?: null
66
-  ): (component: Com) => ComponentType<CP & DP>;
67
-
68
-  declare export function connect<Com: ComponentType<*>>(
69
-    mapStateToProps?: null,
70
-    mapDispatchToProps?: null
71
-  ): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>;
72
-
73
-  declare export function connect<
74
-    Com: ComponentType<*>,
75
-    A,
58
+  declare type Bind<D> = <A, R>((...A) => R) => (...A) => $Call<D, R>;
59
+
60
+  declare type MapDispatchToPropsFn<D, -OP, +DP> =
61
+    | ((dispatch: D, ownProps: OP) => DP)
62
+    // If you want to use the factory function but get a strange error
63
+    // like "function is not an object" then just type the factory function
64
+    // like this:
65
+    // const factory: (Dispatch, OwnProps) => (Dispatch, OwnProps) => DispatchProps
66
+    // and provide the DispatchProps type to the DP type parameter.
67
+    | ((dispatch: D, ownProps: OP) => (dispatch: D, ownProps: OP) => DP);
68
+
69
+  declare class ConnectedComponent<OP, +WC> extends React$Component<OP> {
70
+    static +WrappedComponent: WC;
71
+    getWrappedInstance(): React$ElementRef<WC>;
72
+  }
73
+  // The connection of the Wrapped Component and the Connected Component
74
+  // happens here in `MP: P`. It means that type wise MP belongs to P,
75
+  // so to say MP >= P.
76
+  declare type Connector<P, OP, MP: P> = <WC: React$ComponentType<P>>(
77
+    WC,
78
+  ) => Class<ConnectedComponent<OP, WC>> & WC;
79
+
80
+  // No `mergeProps` argument
81
+
82
+  // Got error like inexact OwnProps is incompatible with exact object type?
83
+  // Just make the OP parameter for `connect()` an exact object.
84
+  declare type MergeOP<OP, D> = {| ...$Exact<OP>, dispatch: D |};
85
+  declare type MergeOPSP<OP, SP, D> = {| ...$Exact<OP>, ...SP, dispatch: D |};
86
+  declare type MergeOPDP<OP, DP> = {| ...$Exact<OP>, ...DP |};
87
+  declare type MergeOPSPDP<OP, SP, DP> = {| ...$Exact<OP>, ...SP, ...DP |};
88
+
89
+  declare export function connect<-P, -OP, -SP, -DP, -S, -D>(
90
+    mapStateToProps?: null | void,
91
+    mapDispatchToProps?: null | void,
92
+    mergeProps?: null | void,
93
+    options?: ?Options<S, OP, {||}, MergeOP<OP, D>>,
94
+  ): Connector<P, OP, MergeOP<OP, D>>;
95
+
96
+  declare export function connect<-P, -OP, -SP, -DP, -S, -D>(
97
+    // If you get error here try adding return type to your mapStateToProps function
98
+    mapStateToProps: MapStateToProps<S, OP, SP>,
99
+    mapDispatchToProps?: null | void,
100
+    mergeProps?: null | void,
101
+    options?: ?Options<S, OP, SP, MergeOPSP<OP, SP, D>>,
102
+  ): Connector<P, OP, MergeOPSP<OP, SP, D>>;
103
+
104
+  // In this case DP is an object of functions which has been bound to dispatch
105
+  // by the given mapDispatchToProps function.
106
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
107
+    mapStateToProps: null | void,
108
+    mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
109
+    mergeProps?: null | void,
110
+    options?: ?Options<S, OP, {||}, MergeOPDP<OP, DP>>,
111
+  ): Connector<P, OP, MergeOPDP<OP, DP>>;
112
+
113
+  // In this case DP is an object of action creators not yet bound to dispatch,
114
+  // this difference is not important in the vanila redux,
115
+  // but in case of usage with redux-thunk, the return type may differ.
116
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
117
+    mapStateToProps: null | void,
118
+    mapDispatchToProps: DP,
119
+    mergeProps?: null | void,
120
+    options?: ?Options<S, OP, {||}, MergeOPDP<OP, DP>>,
121
+  ): Connector<P, OP, MergeOPDP<OP, $ObjMap<DP, Bind<D>>>>;
122
+
123
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
124
+    // If you get error here try adding return type to your mapStateToProps function
125
+    mapStateToProps: MapStateToProps<S, OP, SP>,
126
+    mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
127
+    mergeProps?: null | void,
128
+    options?: ?Options<S, OP, SP, {| ...OP, ...SP, ...DP |}>,
129
+  ): Connector<P, OP, {| ...OP, ...SP, ...DP |}>;
130
+
131
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
132
+    // If you get error here try adding return type to your mapStateToProps function
133
+    mapStateToProps: MapStateToProps<S, OP, SP>,
134
+    mapDispatchToProps: DP,
135
+    mergeProps?: null | void,
136
+    options?: ?Options<S, OP, SP, MergeOPSPDP<OP, SP, DP>>,
137
+  ): Connector<P, OP, MergeOPSPDP<OP, SP, $ObjMap<DP, Bind<D>>>>;
138
+
139
+  // With `mergeProps` argument
140
+
141
+  declare type MergeProps<+P, -OP, -SP, -DP> = (
142
+    stateProps: SP,
143
+    dispatchProps: DP,
144
+    ownProps: OP,
145
+  ) => P;
146
+
147
+  declare export function connect<-P, -OP, -SP: {||}, -DP: {||}, S, D>(
148
+    mapStateToProps: null | void,
149
+    mapDispatchToProps: null | void,
150
+    // If you get error here try adding return type to you mapStateToProps function
151
+    mergeProps: MergeProps<P, OP, {||}, {| dispatch: D |}>,
152
+    options?: ?Options<S, OP, {||}, P>,
153
+  ): Connector<P, OP, P>;
154
+
155
+  declare export function connect<-P, -OP, -SP, -DP: {||}, S, D>(
156
+    mapStateToProps: MapStateToProps<S, OP, SP>,
157
+    mapDispatchToProps: null | void,
158
+    // If you get error here try adding return type to you mapStateToProps function
159
+    mergeProps: MergeProps<P, OP, SP, {| dispatch: D |}>,
160
+    options?: ?Options<S, OP, SP, P>,
161
+  ): Connector<P, OP, P>;
162
+
163
+  // In this case DP is an object of functions which has been bound to dispatch
164
+  // by the given mapDispatchToProps function.
165
+  declare export function connect<-P, -OP, -SP: {||}, -DP, S, D>(
166
+    mapStateToProps: null | void,
167
+    mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
168
+    mergeProps: MergeProps<P, OP, {||}, DP>,
169
+    options?: ?Options<S, OP, {||}, P>,
170
+  ): Connector<P, OP, P>;
171
+
172
+  // In this case DP is an object of action creators not yet bound to dispatch,
173
+  // this difference is not important in the vanila redux,
174
+  // but in case of usage with redux-thunk, the return type may differ.
175
+  declare export function connect<-P, -OP, -SP: {||}, -DP, S, D>(
176
+    mapStateToProps: null | void,
177
+    mapDispatchToProps: DP,
178
+    mergeProps: MergeProps<P, OP, {||}, $ObjMap<DP, Bind<D>>>,
179
+    options?: ?Options<S, OP, {||}, P>,
180
+  ): Connector<P, OP, P>;
181
+
182
+  // In this case DP is an object of functions which has been bound to dispatch
183
+  // by the given mapDispatchToProps function.
184
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
185
+    mapStateToProps: MapStateToProps<S, OP, SP>,
186
+    mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
187
+    mergeProps: MergeProps<P, OP, SP, DP>,
188
+    options?: ?Options<S, OP, SP, P>,
189
+  ): Connector<P, OP, P>;
190
+
191
+  // In this case DP is an object of action creators not yet bound to dispatch,
192
+  // this difference is not important in the vanila redux,
193
+  // but in case of usage with redux-thunk, the return type may differ.
194
+  declare export function connect<-P, -OP, -SP, -DP, S, D>(
195
+    mapStateToProps: MapStateToProps<S, OP, SP>,
196
+    mapDispatchToProps: DP,
197
+    mergeProps: MergeProps<P, OP, SP, $ObjMap<DP, Bind<D>>>,
198
+    options?: ?Options<S, OP, SP, P>,
199
+  ): Connector<P, OP, P>;
200
+
201
+  // ------------------------------------------------------------
202
+  // Typings for Provider
203
+  // ------------------------------------------------------------
204
+
205
+  declare export class Provider<Store> extends React$Component<{
206
+    store: Store,
207
+    children?: React$Node,
208
+  }> {}
209
+
210
+  declare export function createProvider(
211
+    storeKey?: string,
212
+    subKey?: string,
213
+  ): Class<Provider<*>>;
214
+
215
+  // ------------------------------------------------------------
216
+  // Typings for connectAdvanced()
217
+  // ------------------------------------------------------------
218
+
219
+  declare type ConnectAdvancedOptions = {
220
+    getDisplayName?: (name: string) => string,
221
+    methodName?: string,
222
+    renderCountProp?: string,
223
+    shouldHandleStateChanges?: boolean,
224
+    storeKey?: string,
225
+    withRef?: boolean,
226
+  };
227
+
228
+  declare type SelectorFactoryOptions<Com> = {
229
+    getDisplayName: (name: string) => string,
230
+    methodName: string,
231
+    renderCountProp: ?string,
232
+    shouldHandleStateChanges: boolean,
233
+    storeKey: string,
234
+    withRef: boolean,
235
+    displayName: string,
236
+    wrappedComponentName: string,
237
+    WrappedComponent: Com,
238
+  };
239
+
240
+  declare type MapStateToPropsEx<S: Object, SP: Object, RSP: Object> = (
241
+    state: S,
242
+    props: SP,
243
+  ) => RSP;
244
+
245
+  declare type SelectorFactory<
246
+    Com: React$ComponentType<*>,
247
+    Dispatch,
76 248
     S: Object,
77
-    DP: Object,
78
-    SP: Object,
79
-    RSP: Object,
80
-    RDP: Object,
81
-    CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>
82
-    >(
83
-    mapStateToProps: MapStateToProps<S, SP, RSP>,
84
-    mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
85
-  ): (component: Com) => ComponentType<CP & SP & DP>;
86
-
87
-  declare export function connect<
88
-    Com: ComponentType<*>,
89
-    A,
90 249
     OP: Object,
91
-    DP: Object,
92
-    PR: Object,
93
-    CP: $Diff<ElementConfig<Com>, DP>
94
-    >(
95
-    mapStateToProps?: null,
96
-    mapDispatchToProps: MapDispatchToProps<A, OP, DP>
97
-  ): (Com) => ComponentType<CP & OP>;
98
-
99
-  declare export function connect<
100
-    Com: ComponentType<*>,
101
-    MDP: Object
102
-    >(
103
-    mapStateToProps?: null,
104
-    mapDispatchToProps: MDP
105
-  ): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>;
106
-
107
-  declare export function connect<
108
-    Com: ComponentType<*>,
109
-    S: Object,
110
-    SP: Object,
111
-    RSP: Object,
112
-    MDP: Object,
113
-    CP: $Diff<ElementConfig<Com>, RSP>
114
-    >(
115
-    mapStateToProps: MapStateToProps<S, SP, RSP>,
116
-    mapDispatchToPRops: MDP
117
-  ): (component: Com) => ComponentType<$Diff<CP, MDP> & SP>;
118
-
119
-  declare export function connect<
120
-    Com: ComponentType<*>,
121
-    A,
122
-    S: Object,
123
-    DP: Object,
124
-    SP: Object,
125
-    RSP: Object,
126
-    RDP: Object,
127
-    MP: Object,
128
-    RMP: Object,
129
-    CP: $Diff<ElementConfig<Com>, RMP>
130
-    >(
131
-    mapStateToProps: MapStateToProps<S, SP, RSP>,
132
-    mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
133
-    mergeProps: MergeProps<RSP, RDP, MP, RMP>
134
-  ): (component: Com) => ComponentType<CP & SP & DP & MP>;
135
-
136
-  declare export function connect<
137
-    Com: ComponentType<*>,
138
-    A,
139
-    S: Object,
140
-    DP: Object,
141
-    SP: Object,
142
-    RSP: Object,
143
-    RDP: Object,
144
-    MDP: Object,
145
-    MP: Object,
146
-    RMP: Object,
147
-    CP: $Diff<ElementConfig<Com>, RMP>
148
-    >(
149
-    mapStateToProps: MapStateToProps<S, SP, RSP>,
150
-    mapDispatchToProps: MDP,
151
-    mergeProps: MergeProps<RSP, RDP, MP, RMP>
152
-  ): (component: Com) => ComponentType<CP & SP & DP & MP>;
153
-
154
-  declare export function connect<Com: ComponentType<*>,
155
-    A,
156
-    S: Object,
157
-    DP: Object,
158
-    SP: Object,
159
-    RSP: Object,
160
-    RDP: Object,
161
-    MP: Object,
162
-    RMP: Object
163
-    >(
164
-    mapStateToProps: ?MapStateToProps<S, SP, RSP>,
165
-    mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
166
-    mergeProps: ?MergeProps<RSP, RDP, MP, RMP>,
167
-    options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
168
-  ): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
169
-
170
-  declare export function connect<Com: ComponentType<*>,
171
-    A,
250
+    EFO: Object,
251
+    CP: Object,
252
+  > = (
253
+    dispatch: Dispatch,
254
+    factoryOptions: SelectorFactoryOptions<Com> & EFO,
255
+  ) => MapStateToPropsEx<S, OP, CP>;
256
+
257
+  declare export function connectAdvanced<
258
+    Com: React$ComponentType<*>,
259
+    D,
172 260
     S: Object,
173
-    DP: Object,
174
-    SP: Object,
175
-    RSP: Object,
176
-    RDP: Object,
177
-    MDP: Object,
178
-    MP: Object,
179
-    RMP: Object
180
-    >(
181
-    mapStateToProps: ?MapStateToProps<S, SP, RSP>,
182
-    mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
183
-    mergeProps: MDP,
184
-    options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
185
-  ): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
261
+    OP: Object,
262
+    CP: Object,
263
+    EFO: Object,
264
+    ST: { [_: $Keys<Com>]: any },
265
+  >(
266
+    selectorFactory: SelectorFactory<Com, D, S, OP, EFO, CP>,
267
+    connectAdvancedOptions: ?(ConnectAdvancedOptions & EFO),
268
+  ): (component: Com) => React$ComponentType<OP> & $Shape<ST>;
186 269
 
187 270
   declare export default {
188 271
     Provider: typeof Provider,
189 272
     createProvider: typeof createProvider,
190 273
     connect: typeof connect,
274
+    connectAdvanced: typeof connectAdvanced,
191 275
   };
192 276
 }

flow-typed/npm/redux_v3.x.x.js → flow-typed/npm/redux_v4.x.x.js View File

@@ -1,3 +1,6 @@
1
+// flow-typed signature: df80bdd535bfed9cf3223e077f3b4543
2
+// flow-typed version: c4c8963c9c/redux_v4.x.x/flow_>=v0.55.x
3
+
1 4
 declare module 'redux' {
2 5
 
3 6
   /*

Loading…
Cancel
Save