flow: update type definitions
This commit is contained in:
parent
0e92e73789
commit
278d3a163b
|
@ -1,5 +1,5 @@
|
|||
// flow-typed signature: d71d314ca25fc6c20610a3ba80af9df0
|
||||
// flow-typed version: 9698a46399/jquery_v3.x.x/flow_>=v0.28.x
|
||||
// flow-typed signature: f26fda66e3a551aef37d3b0f53058e6a
|
||||
// flow-typed version: 44ad941b7a/jquery_v3.x.x/flow_>=v0.28.x
|
||||
|
||||
/* eslint-disable max-len, no-unused-vars, flowtype/no-weak-types */
|
||||
|
||||
|
@ -364,6 +364,13 @@ declare class JQueryGenericPromise<T> {
|
|||
failFilter?: (...reasons: any[]) => any,
|
||||
progressFilter?: (...progression: any[]) => any
|
||||
): JQueryPromise<void>;
|
||||
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is rejected.
|
||||
*
|
||||
* @param failFilter An function that is called when the Deferred is rejected.
|
||||
*/
|
||||
catch(failFilter: (...reasons: any[]) => any): JQueryPromise<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -822,7 +829,7 @@ declare class JQueryStatic {
|
|||
*/
|
||||
get(
|
||||
url: string,
|
||||
data?: Object | string,
|
||||
data?: {} | string,
|
||||
success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
|
||||
dataType?: string
|
||||
): JQueryXHR;
|
||||
|
@ -845,7 +852,7 @@ declare class JQueryStatic {
|
|||
*/
|
||||
getJSON(
|
||||
url: string,
|
||||
data?: Object | string,
|
||||
data?: {} | string,
|
||||
success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any
|
||||
): JQueryXHR;
|
||||
/**
|
||||
|
@ -886,7 +893,7 @@ declare class JQueryStatic {
|
|||
*/
|
||||
post(
|
||||
url: string,
|
||||
data?: Object | string,
|
||||
data?: {} | string,
|
||||
success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
|
||||
dataType?: string
|
||||
): JQueryXHR;
|
||||
|
@ -967,7 +974,7 @@ declare class JQueryStatic {
|
|||
* @param html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
|
||||
* @param attributes An object of attributes, events, and methods to call on the newly-created element.
|
||||
*/
|
||||
(html: string, attributes: Object): JQuery;
|
||||
(html: string, attributes: {}): JQuery;
|
||||
|
||||
/**
|
||||
* Relinquish jQuery's control of the $ variable.
|
||||
|
@ -1425,7 +1432,7 @@ declare class JQuery {
|
|||
*/
|
||||
load(
|
||||
url: string,
|
||||
data?: string | Object,
|
||||
data?: string | {},
|
||||
complete?: (
|
||||
responseText: string,
|
||||
textStatus: string,
|
||||
|
@ -1482,7 +1489,7 @@ declare class JQuery {
|
|||
*
|
||||
* @param attributes An object of attribute-value pairs to set.
|
||||
*/
|
||||
attr(attributes: Object): JQuery;
|
||||
attr(attributes: {}): JQuery;
|
||||
/**
|
||||
* Get the value of an attribute for the first element in the set of matched elements.
|
||||
*
|
||||
|
@ -1532,7 +1539,7 @@ declare class JQuery {
|
|||
*
|
||||
* @param properties An object of property-value pairs to set.
|
||||
*/
|
||||
prop(properties: Object): JQuery;
|
||||
prop(properties: {}): JQuery;
|
||||
/**
|
||||
* Set one or more properties for the set of matched elements.
|
||||
*
|
||||
|
@ -1598,7 +1605,7 @@ declare class JQuery {
|
|||
/**
|
||||
* Get the current value of the first element in the set of matched elements.
|
||||
*/
|
||||
val(_: void): any;
|
||||
val(_: void): string | string[] | number;
|
||||
/**
|
||||
* Set the value of each element in the set of matched elements.
|
||||
*
|
||||
|
@ -1634,7 +1641,7 @@ declare class JQuery {
|
|||
*
|
||||
* @param properties An object of property-value pairs to set.
|
||||
*/
|
||||
css(properties: Object): JQuery;
|
||||
css(properties: {}): JQuery;
|
||||
/**
|
||||
* Get the value of style properties for the first element in the set of matched elements.
|
||||
*
|
||||
|
@ -1847,7 +1854,7 @@ declare class JQuery {
|
|||
* @param complete A function to call once the animation is complete.
|
||||
*/
|
||||
animate(
|
||||
properties: Object,
|
||||
properties: {},
|
||||
duration?: string | number,
|
||||
complete?: Function
|
||||
): JQuery;
|
||||
|
@ -1860,7 +1867,7 @@ declare class JQuery {
|
|||
* @param complete A function to call once the animation is complete.
|
||||
*/
|
||||
animate(
|
||||
properties: Object,
|
||||
properties: {},
|
||||
duration?: string | number,
|
||||
easing?: string,
|
||||
complete?: Function
|
||||
|
@ -1871,7 +1878,7 @@ declare class JQuery {
|
|||
* @param properties An object of CSS properties and values that the animation will move toward.
|
||||
* @param options A map of additional options to pass to the method.
|
||||
*/
|
||||
animate(properties: Object, options: JQueryAnimationOptions): JQuery;
|
||||
animate(properties: {}, options: JQueryAnimationOptions): JQuery;
|
||||
|
||||
/**
|
||||
* Set a timer to delay execution of subsequent items in the queue.
|
||||
|
@ -2920,14 +2927,14 @@ declare class JQuery {
|
|||
* @param eventType A string containing a JavaScript event type, such as click or submit.
|
||||
* @param extraParameters Additional parameters to pass along to the event handler.
|
||||
*/
|
||||
trigger(eventType: string, extraParameters?: any[] | Object): JQuery;
|
||||
trigger(eventType: string, extraParameters?: any[] | {}): JQuery;
|
||||
/**
|
||||
* Execute all handlers and behaviors attached to the matched elements for the given event type.
|
||||
*
|
||||
* @param event A jQuery.Event object.
|
||||
* @param extraParameters Additional parameters to pass along to the event handler.
|
||||
*/
|
||||
trigger(event: JQueryEventObject, extraParameters?: any[] | Object): JQuery;
|
||||
trigger(event: JQueryEventObject, extraParameters?: any[] | {}): JQuery;
|
||||
|
||||
/**
|
||||
* Execute all handlers attached to an element for an event.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,329 +0,0 @@
|
|||
// flow-typed signature: c30aa20539f52183d4d30dd36d8ab9c2
|
||||
// flow-typed version: 886cf7c002/moment_v2.3.x/flow_>=v0.63.x
|
||||
|
||||
type moment$MomentOptions = {
|
||||
y?: number | string,
|
||||
year?: number | string,
|
||||
years?: number | string,
|
||||
M?: number | string,
|
||||
month?: number | string,
|
||||
months?: number | string,
|
||||
d?: number | string,
|
||||
day?: number | string,
|
||||
days?: number | string,
|
||||
date?: number | string,
|
||||
h?: number | string,
|
||||
hour?: number | string,
|
||||
hours?: number | string,
|
||||
m?: number | string,
|
||||
minute?: number | string,
|
||||
minutes?: number | string,
|
||||
s?: number | string,
|
||||
second?: number | string,
|
||||
seconds?: number | string,
|
||||
ms?: number | string,
|
||||
millisecond?: number | string,
|
||||
milliseconds?: number | string
|
||||
};
|
||||
|
||||
type moment$MomentObject = {
|
||||
years: number,
|
||||
months: number,
|
||||
date: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number,
|
||||
milliseconds: number
|
||||
};
|
||||
|
||||
type moment$MomentCreationData = {
|
||||
input: string,
|
||||
format: string,
|
||||
locale: Object,
|
||||
isUTC: boolean,
|
||||
strict: boolean
|
||||
};
|
||||
|
||||
type moment$CalendarFormat = string | ((moment: moment$Moment) => string);
|
||||
|
||||
type moment$CalendarFormats = {
|
||||
sameDay?: moment$CalendarFormat,
|
||||
nextDay?: moment$CalendarFormat,
|
||||
nextWeek?: moment$CalendarFormat,
|
||||
lastDay?: moment$CalendarFormat,
|
||||
lastWeek?: moment$CalendarFormat,
|
||||
sameElse?: moment$CalendarFormat
|
||||
};
|
||||
|
||||
declare class moment$LocaleData {
|
||||
months(moment: moment$Moment): string,
|
||||
monthsShort(moment: moment$Moment): string,
|
||||
monthsParse(month: string): number,
|
||||
weekdays(moment: moment$Moment): string,
|
||||
weekdaysShort(moment: moment$Moment): string,
|
||||
weekdaysMin(moment: moment$Moment): string,
|
||||
weekdaysParse(weekDay: string): number,
|
||||
longDateFormat(dateFormat: string): string,
|
||||
isPM(date: string): boolean,
|
||||
meridiem(hours: number, minutes: number, isLower: boolean): string,
|
||||
calendar(
|
||||
key:
|
||||
| "sameDay"
|
||||
| "nextDay"
|
||||
| "lastDay"
|
||||
| "nextWeek"
|
||||
| "prevWeek"
|
||||
| "sameElse",
|
||||
moment: moment$Moment
|
||||
): string,
|
||||
relativeTime(
|
||||
number: number,
|
||||
withoutSuffix: boolean,
|
||||
key: "s" | "m" | "mm" | "h" | "hh" | "d" | "dd" | "M" | "MM" | "y" | "yy",
|
||||
isFuture: boolean
|
||||
): string,
|
||||
pastFuture(diff: any, relTime: string): string,
|
||||
ordinal(number: number): string,
|
||||
preparse(str: string): any,
|
||||
postformat(str: string): any,
|
||||
week(moment: moment$Moment): string,
|
||||
invalidDate(): string,
|
||||
firstDayOfWeek(): number,
|
||||
firstDayOfYear(): number
|
||||
}
|
||||
declare class moment$MomentDuration {
|
||||
humanize(suffix?: boolean): string,
|
||||
milliseconds(): number,
|
||||
asMilliseconds(): number,
|
||||
seconds(): number,
|
||||
asSeconds(): number,
|
||||
minutes(): number,
|
||||
asMinutes(): number,
|
||||
hours(): number,
|
||||
asHours(): number,
|
||||
days(): number,
|
||||
asDays(): number,
|
||||
months(): number,
|
||||
asMonths(): number,
|
||||
years(): number,
|
||||
asYears(): number,
|
||||
add(value: number | moment$MomentDuration | Object, unit?: string): this,
|
||||
subtract(value: number | moment$MomentDuration | Object, unit?: string): this,
|
||||
as(unit: string): number,
|
||||
get(unit: string): number,
|
||||
toJSON(): string,
|
||||
toISOString(): string,
|
||||
isValid(): boolean
|
||||
}
|
||||
declare class moment$Moment {
|
||||
static ISO_8601: string,
|
||||
static (
|
||||
string?: string,
|
||||
format?: string | Array<string>,
|
||||
strict?: boolean
|
||||
): moment$Moment,
|
||||
static (
|
||||
string?: string,
|
||||
format?: string | Array<string>,
|
||||
locale?: string,
|
||||
strict?: boolean
|
||||
): moment$Moment,
|
||||
static (
|
||||
initDate: ?Object | number | Date | Array<number> | moment$Moment | string
|
||||
): moment$Moment,
|
||||
static unix(seconds: number): moment$Moment,
|
||||
static utc(): moment$Moment,
|
||||
static utc(number: number | Array<number>): moment$Moment,
|
||||
static utc(
|
||||
str: string,
|
||||
str2?: string | Array<string>,
|
||||
str3?: string
|
||||
): moment$Moment,
|
||||
static utc(moment: moment$Moment): moment$Moment,
|
||||
static utc(date: Date): moment$Moment,
|
||||
static parseZone(): moment$Moment,
|
||||
static parseZone(rawDate: string): moment$Moment,
|
||||
static parseZone(
|
||||
rawDate: string,
|
||||
format: string | Array<string>
|
||||
): moment$Moment,
|
||||
static parseZone(
|
||||
rawDate: string,
|
||||
format: string,
|
||||
strict: boolean
|
||||
): moment$Moment,
|
||||
static parseZone(
|
||||
rawDate: string,
|
||||
format: string,
|
||||
locale: string,
|
||||
strict: boolean
|
||||
): moment$Moment,
|
||||
isValid(): boolean,
|
||||
invalidAt(): 0 | 1 | 2 | 3 | 4 | 5 | 6,
|
||||
creationData(): moment$MomentCreationData,
|
||||
millisecond(number: number): this,
|
||||
milliseconds(number: number): this,
|
||||
millisecond(): number,
|
||||
milliseconds(): number,
|
||||
second(number: number): this,
|
||||
seconds(number: number): this,
|
||||
second(): number,
|
||||
seconds(): number,
|
||||
minute(number: number): this,
|
||||
minutes(number: number): this,
|
||||
minute(): number,
|
||||
minutes(): number,
|
||||
hour(number: number): this,
|
||||
hours(number: number): this,
|
||||
hour(): number,
|
||||
hours(): number,
|
||||
date(number: number): this,
|
||||
dates(number: number): this,
|
||||
date(): number,
|
||||
dates(): number,
|
||||
day(day: number | string): this,
|
||||
days(day: number | string): this,
|
||||
day(): number,
|
||||
days(): number,
|
||||
weekday(number: number): this,
|
||||
weekday(): number,
|
||||
isoWeekday(number: number): this,
|
||||
isoWeekday(): number,
|
||||
dayOfYear(number: number): this,
|
||||
dayOfYear(): number,
|
||||
week(number: number): this,
|
||||
weeks(number: number): this,
|
||||
week(): number,
|
||||
weeks(): number,
|
||||
isoWeek(number: number): this,
|
||||
isoWeeks(number: number): this,
|
||||
isoWeek(): number,
|
||||
isoWeeks(): number,
|
||||
month(number: number): this,
|
||||
months(number: number): this,
|
||||
month(): number,
|
||||
months(): number,
|
||||
quarter(number: number): this,
|
||||
quarter(): number,
|
||||
year(number: number): this,
|
||||
years(number: number): this,
|
||||
year(): number,
|
||||
years(): number,
|
||||
weekYear(number: number): this,
|
||||
weekYear(): number,
|
||||
isoWeekYear(number: number): this,
|
||||
isoWeekYear(): number,
|
||||
weeksInYear(): number,
|
||||
isoWeeksInYear(): number,
|
||||
get(string: string): number,
|
||||
set(unit: string, value: number): this,
|
||||
set(options: { [unit: string]: number }): this,
|
||||
static max(...dates: Array<moment$Moment>): moment$Moment,
|
||||
static max(dates: Array<moment$Moment>): moment$Moment,
|
||||
static min(...dates: Array<moment$Moment>): moment$Moment,
|
||||
static min(dates: Array<moment$Moment>): moment$Moment,
|
||||
add(
|
||||
value: number | moment$MomentDuration | moment$Moment | Object,
|
||||
unit?: string
|
||||
): this,
|
||||
subtract(
|
||||
value: number | moment$MomentDuration | moment$Moment | string | Object,
|
||||
unit?: string
|
||||
): this,
|
||||
startOf(unit: string): this,
|
||||
endOf(unit: string): this,
|
||||
local(): this,
|
||||
utc(): this,
|
||||
utcOffset(
|
||||
offset: number | string,
|
||||
keepLocalTime?: boolean,
|
||||
keepMinutes?: boolean
|
||||
): this,
|
||||
utcOffset(): number,
|
||||
format(format?: string): string,
|
||||
fromNow(removeSuffix?: boolean): string,
|
||||
from(
|
||||
value: moment$Moment | string | number | Date | Array<number>,
|
||||
removePrefix?: boolean
|
||||
): string,
|
||||
toNow(removePrefix?: boolean): string,
|
||||
to(
|
||||
value: moment$Moment | string | number | Date | Array<number>,
|
||||
removePrefix?: boolean
|
||||
): string,
|
||||
calendar(refTime?: any, formats?: moment$CalendarFormats): string,
|
||||
diff(
|
||||
date: moment$Moment | string | number | Date | Array<number>,
|
||||
format?: string,
|
||||
floating?: boolean
|
||||
): number,
|
||||
valueOf(): number,
|
||||
unix(): number,
|
||||
daysInMonth(): number,
|
||||
toDate(): Date,
|
||||
toArray(): Array<number>,
|
||||
toJSON(): string,
|
||||
toISOString(
|
||||
keepOffset?: boolean
|
||||
): string,
|
||||
toObject(): moment$MomentObject,
|
||||
isBefore(
|
||||
date?: moment$Moment | string | number | Date | Array<number>,
|
||||
units?: ?string
|
||||
): boolean,
|
||||
isSame(
|
||||
date?: moment$Moment | string | number | Date | Array<number>,
|
||||
units?: ?string
|
||||
): boolean,
|
||||
isAfter(
|
||||
date?: moment$Moment | string | number | Date | Array<number>,
|
||||
units?: ?string
|
||||
): boolean,
|
||||
isSameOrBefore(
|
||||
date?: moment$Moment | string | number | Date | Array<number>,
|
||||
units?: ?string
|
||||
): boolean,
|
||||
isSameOrAfter(
|
||||
date?: moment$Moment | string | number | Date | Array<number>,
|
||||
units?: ?string
|
||||
): boolean,
|
||||
isBetween(
|
||||
fromDate: moment$Moment | string | number | Date | Array<number>,
|
||||
toDate?: ?moment$Moment | string | number | Date | Array<number>,
|
||||
granularity?: ?string,
|
||||
inclusion?: ?string
|
||||
): boolean,
|
||||
isDST(): boolean,
|
||||
isDSTShifted(): boolean,
|
||||
isLeapYear(): boolean,
|
||||
clone(): moment$Moment,
|
||||
static isMoment(obj: any): boolean,
|
||||
static isDate(obj: any): boolean,
|
||||
static locale(locale: string, localeData?: Object): string,
|
||||
static updateLocale(locale: string, localeData?: ?Object): void,
|
||||
static locale(locales: Array<string>): string,
|
||||
locale(locale: string, customization?: Object | null): moment$Moment,
|
||||
locale(): string,
|
||||
static months(): Array<string>,
|
||||
static monthsShort(): Array<string>,
|
||||
static weekdays(): Array<string>,
|
||||
static weekdaysShort(): Array<string>,
|
||||
static weekdaysMin(): Array<string>,
|
||||
static months(): string,
|
||||
static monthsShort(): string,
|
||||
static weekdays(): string,
|
||||
static weekdaysShort(): string,
|
||||
static weekdaysMin(): string,
|
||||
static localeData(key?: string): moment$LocaleData,
|
||||
static duration(
|
||||
value: number | Object | string,
|
||||
unit?: string
|
||||
): moment$MomentDuration,
|
||||
static isDuration(obj: any): boolean,
|
||||
static normalizeUnits(unit: string): string,
|
||||
static invalid(object: any): moment$Moment
|
||||
}
|
||||
|
||||
declare module "moment" {
|
||||
declare module.exports: Class<moment$Moment>;
|
||||
}
|
|
@ -1,192 +1,276 @@
|
|||
// flow-typed signature: d4e793bc07ef1dc9906a244b12960f7b
|
||||
// flow-typed version: cf33ff8762/react-redux_v5.x.x/flow_>=v0.63.0
|
||||
// flow-typed signature: f06f00c3ad0cfedb90c0c6de04b219f3
|
||||
// flow-typed version: 3a6d556e4b/react-redux_v5.x.x/flow_>=v0.89.x
|
||||
|
||||
import type { Dispatch, Store } from "redux";
|
||||
/**
|
||||
The order of type arguments for connect() is as follows:
|
||||
|
||||
declare module "react-redux" {
|
||||
import type { ComponentType, ElementConfig } from 'react';
|
||||
connect<Props, OwnProps, StateProps, DispatchProps, State, Dispatch>(…)
|
||||
|
||||
declare export class Provider<S, A> extends React$Component<{
|
||||
store: Store<S, A>,
|
||||
children?: any
|
||||
}> {}
|
||||
In Flow v0.89 only the first two are mandatory to specify. Other 4 can be repaced with the new awesome type placeholder:
|
||||
|
||||
declare export function createProvider(
|
||||
storeKey?: string,
|
||||
subKey?: string
|
||||
): Provider<*, *>;
|
||||
connect<Props, OwnProps, _, _, _, _>(…)
|
||||
|
||||
/*
|
||||
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
|
||||
A = Action
|
||||
D = Dispatch
|
||||
OP = OwnProps
|
||||
SP = StateProps
|
||||
DP = DispatchProps
|
||||
MP = Merge props
|
||||
MDP = Map dispatch to props object
|
||||
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 type MapStateToProps<S: Object, SP: Object, RSP: Object> = (state: S, props: SP) => RSP;
|
||||
declare module "react-redux" {
|
||||
// ------------------------------------------------------------
|
||||
// Typings for connect()
|
||||
// ------------------------------------------------------------
|
||||
|
||||
declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP;
|
||||
|
||||
declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = (
|
||||
stateProps: SP,
|
||||
dispatchProps: DP,
|
||||
ownProps: MP
|
||||
) => RMP;
|
||||
|
||||
declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {|
|
||||
declare export type Options<S, OP, SP, MP> = {|
|
||||
pure?: boolean,
|
||||
withRef?: boolean,
|
||||
areStatesEqual?: (next: S, prev: S) => boolean,
|
||||
areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
|
||||
areStatePropsEqual?: (next: RSP, prev: RSP) => boolean,
|
||||
areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean,
|
||||
storeKey?: string
|
||||
areStatePropsEqual?: (next: SP, prev: SP) => boolean,
|
||||
areMergedPropsEqual?: (next: MP, prev: MP) => boolean,
|
||||
storeKey?: string,
|
||||
|};
|
||||
|
||||
declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>;
|
||||
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 export function connect<
|
||||
Com: ComponentType<*>,
|
||||
declare type Bind<D> = <A, R>((...A) => R) => (...A) => $Call<D, R>;
|
||||
|
||||
declare type MapDispatchToPropsFn<D, -OP, +DP> =
|
||||
| ((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<OP, +WC> extends React$Component<OP> {
|
||||
static +WrappedComponent: WC;
|
||||
getWrappedInstance(): React$ElementRef<WC>;
|
||||
}
|
||||
// The connection of the Wrapped Component and the Connected Component
|
||||
// happens here in `MP: P`. It means that type wise MP belongs to P,
|
||||
// so to say MP >= P.
|
||||
declare type Connector<P, OP, MP: P> = <WC: React$ComponentType<P>>(
|
||||
WC,
|
||||
) => Class<ConnectedComponent<OP, WC>> & WC;
|
||||
|
||||
// No `mergeProps` argument
|
||||
|
||||
// Got error like inexact OwnProps is incompatible with exact object type?
|
||||
// Just make the OP parameter for `connect()` an exact object.
|
||||
declare type MergeOP<OP, D> = {| ...$Exact<OP>, dispatch: D |};
|
||||
declare type MergeOPSP<OP, SP, D> = {| ...$Exact<OP>, ...SP, dispatch: D |};
|
||||
declare type MergeOPDP<OP, DP> = {| ...$Exact<OP>, ...DP |};
|
||||
declare type MergeOPSPDP<OP, SP, DP> = {| ...$Exact<OP>, ...SP, ...DP |};
|
||||
|
||||
declare export function connect<-P, -OP, -SP, -DP, -S, -D>(
|
||||
mapStateToProps?: null | void,
|
||||
mapDispatchToProps?: null | void,
|
||||
mergeProps?: null | void,
|
||||
options?: ?Options<S, OP, {||}, MergeOP<OP, D>>,
|
||||
): Connector<P, OP, MergeOP<OP, D>>;
|
||||
|
||||
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<S, OP, SP>,
|
||||
mapDispatchToProps?: null | void,
|
||||
mergeProps?: null | void,
|
||||
options?: ?Options<S, OP, SP, MergeOPSP<OP, SP, D>>,
|
||||
): Connector<P, OP, MergeOPSP<OP, SP, D>>;
|
||||
|
||||
// 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<D, OP, DP>,
|
||||
mergeProps?: null | void,
|
||||
options?: ?Options<S, OP, {||}, MergeOPDP<OP, DP>>,
|
||||
): Connector<P, OP, MergeOPDP<OP, DP>>;
|
||||
|
||||
// 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<S, OP, {||}, MergeOPDP<OP, DP>>,
|
||||
): Connector<P, OP, MergeOPDP<OP, $ObjMap<DP, Bind<D>>>>;
|
||||
|
||||
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<S, OP, SP>,
|
||||
mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
|
||||
mergeProps?: null | void,
|
||||
options?: ?Options<S, OP, SP, {| ...OP, ...SP, ...DP |}>,
|
||||
): Connector<P, OP, {| ...OP, ...SP, ...DP |}>;
|
||||
|
||||
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<S, OP, SP>,
|
||||
mapDispatchToProps: DP,
|
||||
mergeProps?: null | void,
|
||||
options?: ?Options<S, OP, SP, MergeOPSPDP<OP, SP, DP>>,
|
||||
): Connector<P, OP, MergeOPSPDP<OP, SP, $ObjMap<DP, Bind<D>>>>;
|
||||
|
||||
// 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<P, OP, {||}, {| dispatch: D |}>,
|
||||
options?: ?Options<S, OP, {||}, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
declare export function connect<-P, -OP, -SP, -DP: {||}, S, D>(
|
||||
mapStateToProps: MapStateToProps<S, OP, SP>,
|
||||
mapDispatchToProps: null | void,
|
||||
// If you get error here try adding return type to you mapStateToProps function
|
||||
mergeProps: MergeProps<P, OP, SP, {| dispatch: D |}>,
|
||||
options?: ?Options<S, OP, SP, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
// 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<D, OP, DP>,
|
||||
mergeProps: MergeProps<P, OP, {||}, DP>,
|
||||
options?: ?Options<S, OP, {||}, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
// 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<P, OP, {||}, $ObjMap<DP, Bind<D>>>,
|
||||
options?: ?Options<S, OP, {||}, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
// 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<S, OP, SP>,
|
||||
mapDispatchToProps: MapDispatchToPropsFn<D, OP, DP>,
|
||||
mergeProps: MergeProps<P, OP, SP, DP>,
|
||||
options?: ?Options<S, OP, SP, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
// 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<S, OP, SP>,
|
||||
mapDispatchToProps: DP,
|
||||
mergeProps: MergeProps<P, OP, SP, $ObjMap<DP, Bind<D>>>,
|
||||
options?: ?Options<S, OP, SP, P>,
|
||||
): Connector<P, OP, P>;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Typings for Provider
|
||||
// ------------------------------------------------------------
|
||||
|
||||
declare export class Provider<Store> extends React$Component<{
|
||||
store: Store,
|
||||
children?: React$Node,
|
||||
}> {}
|
||||
|
||||
declare export function createProvider(
|
||||
storeKey?: string,
|
||||
subKey?: string,
|
||||
): Class<Provider<*>>;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Typings for connectAdvanced()
|
||||
// ------------------------------------------------------------
|
||||
|
||||
declare type ConnectAdvancedOptions = {
|
||||
getDisplayName?: (name: string) => string,
|
||||
methodName?: string,
|
||||
renderCountProp?: string,
|
||||
shouldHandleStateChanges?: boolean,
|
||||
storeKey?: string,
|
||||
withRef?: boolean,
|
||||
};
|
||||
|
||||
declare type SelectorFactoryOptions<Com> = {
|
||||
getDisplayName: (name: string) => string,
|
||||
methodName: string,
|
||||
renderCountProp: ?string,
|
||||
shouldHandleStateChanges: boolean,
|
||||
storeKey: string,
|
||||
withRef: boolean,
|
||||
displayName: string,
|
||||
wrappedComponentName: string,
|
||||
WrappedComponent: Com,
|
||||
};
|
||||
|
||||
declare type MapStateToPropsEx<S: Object, SP: Object, RSP: Object> = (
|
||||
state: S,
|
||||
props: SP,
|
||||
) => RSP;
|
||||
|
||||
declare type SelectorFactory<
|
||||
Com: React$ComponentType<*>,
|
||||
Dispatch,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
RSP: Object,
|
||||
CP: $Diff<OmitDispatch<ElementConfig<Com>>, RSP>
|
||||
>(
|
||||
mapStateToProps: MapStateToProps<S, DP, RSP>,
|
||||
mapDispatchToProps?: null
|
||||
): (component: Com) => ComponentType<CP & DP>;
|
||||
|
||||
declare export function connect<Com: ComponentType<*>>(
|
||||
mapStateToProps?: null,
|
||||
mapDispatchToProps?: null
|
||||
): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
A,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
RDP: Object,
|
||||
CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>
|
||||
>(
|
||||
mapStateToProps: MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
|
||||
): (component: Com) => ComponentType<CP & SP & DP>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
A,
|
||||
OP: Object,
|
||||
DP: Object,
|
||||
PR: Object,
|
||||
CP: $Diff<ElementConfig<Com>, DP>
|
||||
>(
|
||||
mapStateToProps?: null,
|
||||
mapDispatchToProps: MapDispatchToProps<A, OP, DP>
|
||||
): (Com) => ComponentType<CP & OP>;
|
||||
EFO: Object,
|
||||
CP: Object,
|
||||
> = (
|
||||
dispatch: Dispatch,
|
||||
factoryOptions: SelectorFactoryOptions<Com> & EFO,
|
||||
) => MapStateToPropsEx<S, OP, CP>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
MDP: Object
|
||||
>(
|
||||
mapStateToProps?: null,
|
||||
mapDispatchToProps: MDP
|
||||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
declare export function connectAdvanced<
|
||||
Com: React$ComponentType<*>,
|
||||
D,
|
||||
S: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
MDP: Object,
|
||||
CP: $Diff<ElementConfig<Com>, RSP>
|
||||
>(
|
||||
mapStateToProps: MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToPRops: MDP
|
||||
): (component: Com) => ComponentType<$Diff<CP, MDP> & SP>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
A,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
RDP: Object,
|
||||
MP: Object,
|
||||
RMP: Object,
|
||||
CP: $Diff<ElementConfig<Com>, RMP>
|
||||
>(
|
||||
mapStateToProps: MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
|
||||
mergeProps: MergeProps<RSP, RDP, MP, RMP>
|
||||
): (component: Com) => ComponentType<CP & SP & DP & MP>;
|
||||
|
||||
declare export function connect<
|
||||
Com: ComponentType<*>,
|
||||
A,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
RDP: Object,
|
||||
MDP: Object,
|
||||
MP: Object,
|
||||
RMP: Object,
|
||||
CP: $Diff<ElementConfig<Com>, RMP>
|
||||
>(
|
||||
mapStateToProps: MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToProps: MDP,
|
||||
mergeProps: MergeProps<RSP, RDP, MP, RMP>
|
||||
): (component: Com) => ComponentType<CP & SP & DP & MP>;
|
||||
|
||||
declare export function connect<Com: ComponentType<*>,
|
||||
A,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
RDP: Object,
|
||||
MP: Object,
|
||||
RMP: Object
|
||||
>(
|
||||
mapStateToProps: ?MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
|
||||
mergeProps: ?MergeProps<RSP, RDP, MP, RMP>,
|
||||
options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
|
||||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
|
||||
|
||||
declare export function connect<Com: ComponentType<*>,
|
||||
A,
|
||||
S: Object,
|
||||
DP: Object,
|
||||
SP: Object,
|
||||
RSP: Object,
|
||||
RDP: Object,
|
||||
MDP: Object,
|
||||
MP: Object,
|
||||
RMP: Object
|
||||
>(
|
||||
mapStateToProps: ?MapStateToProps<S, SP, RSP>,
|
||||
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
|
||||
mergeProps: MDP,
|
||||
options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
|
||||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
|
||||
OP: Object,
|
||||
CP: Object,
|
||||
EFO: Object,
|
||||
ST: { [_: $Keys<Com>]: any },
|
||||
>(
|
||||
selectorFactory: SelectorFactory<Com, D, S, OP, EFO, CP>,
|
||||
connectAdvancedOptions: ?(ConnectAdvancedOptions & EFO),
|
||||
): (component: Com) => React$ComponentType<OP> & $Shape<ST>;
|
||||
|
||||
declare export default {
|
||||
Provider: typeof Provider,
|
||||
createProvider: typeof createProvider,
|
||||
connect: typeof connect,
|
||||
connectAdvanced: typeof connectAdvanced,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// flow-typed signature: df80bdd535bfed9cf3223e077f3b4543
|
||||
// flow-typed version: c4c8963c9c/redux_v4.x.x/flow_>=v0.55.x
|
||||
|
||||
declare module 'redux' {
|
||||
|
||||
/*
|
Loading…
Reference in New Issue