Skip to content

Commit 57fa649

Browse files
committed
react-intl libdef: Make some React type annotations useful.
Not sure why the TypeScript file is calling it React_2 instead of React...anyway, handle these, like we did in two recent commits.
1 parent 5354a82 commit 57fa649

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

flow-typed/react-intl_vx.x.x.js

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -209,29 +209,29 @@ declare module 'react-intl' {
209209
time: { [key: string]: Intl.DateTimeFormatOptions, ... };
210210
}
211211
declare type FormattableUnit = Unit | Units;
212-
declare export var FormattedDate: React_2.FC<
212+
declare export var FormattedDate: React$StatelessFunctionalComponent<
213213
DateTimeFormatOptions &
214214
CustomFormatConfig & {
215215
value: string | number | Date | void,
216216
...
217217
},
218218
>;
219-
declare export var FormattedDateParts: React_2.FC<
219+
declare export var FormattedDateParts: React$StatelessFunctionalComponent<
220220
FormatDateOptions & {
221221
value: $ElementType<Parameters<$PropertyType<Intl.DateTimeFormat, 'format'>>, 0> | string,
222222
children(val: Intl.DateTimeFormatPart[]): React_2.ReactElement<> | null,
223223
...
224224
},
225225
>;
226-
declare export var FormattedDisplayName: React_2.FC<
226+
declare export var FormattedDisplayName: React$StatelessFunctionalComponent<
227227
DisplayNamesOptions & {
228228
value: string | number | { [key: string]: any },
229229
...
230230
},
231231
>;
232-
declare export var FormattedList: React_2.FC<
232+
declare export var FormattedList: React$StatelessFunctionalComponent<
233233
IntlListFormatOptions & {
234-
value: React_2.Node[],
234+
value: React$Node[],
235235
...
236236
},
237237
>;
@@ -240,33 +240,35 @@ declare module 'react-intl' {
240240
[key: string]:
241241
| PrimitiveType
242242
| React_2.ReactElement<>
243-
| FormatXMLElementFn<React_2.Node, React_2.Node>,
243+
| FormatXMLElementFn<React$Node, React$Node>,
244244
...,
245245
},
246-
> mixins React_2.Component<Props_3<V>> {
246+
// Changed `mixins` to `extends` in TS to Flow translation
247+
> extends React$Component<Props_3<V>> {
247248
static displayName: string;
248249
shouldComponentUpdate(nextProps: Props_3<V>): boolean;
249250
render(): React$Node;
250251
}
251-
declare export var FormattedNumber: React_2.FC<
252+
declare export var FormattedNumber: React$StatelessFunctionalComponent<
252253
NumberFormatOptions &
253254
CustomFormatConfig & {
254255
value: number,
255256
...
256257
},
257258
>;
258-
declare export var FormattedNumberParts: React_2.FC<
259+
declare export var FormattedNumberParts: React$StatelessFunctionalComponent<
259260
$PropertyType<Formatter, 'formatNumber'> & {
260261
value: $ElementType<Parameters<$PropertyType<IntlShape, 'formatNumber'>>, 0>,
261262
children(val: Intl.NumberFormatPart[]): React_2.ReactElement<> | null,
262263
...
263264
},
264265
>;
265-
declare export var FormattedPlural: React_2.FC<WithIntlProps<Props_2>> & {
266-
WrappedComponent: React_2.ComponentType<Props_2>,
266+
declare export var FormattedPlural: React$StatelessFunctionalComponent<WithIntlProps<Props_2>> & {
267+
WrappedComponent: React$ComponentType<Props_2>,
267268
...
268269
};
269-
declare export class FormattedRelativeTime mixins React_2.PureComponent<Props, State_2> {
270+
// Changed `mixins` to `extends` in TS to Flow translation
271+
declare export class FormattedRelativeTime extends React$PureComponent<Props, State_2> {
270272
_updateTimer: any;
271273
static displayName: string;
272274
static defaultProps: Pick<Props, 'unit' | 'value'>;
@@ -279,14 +281,14 @@ declare module 'react-intl' {
279281
static getDerivedStateFromProps(props: Props, state: State_2): $Rest<State_2, { ... }> | null;
280282
render(): React$Node;
281283
}
282-
declare export var FormattedTime: React_2.FC<
284+
declare export var FormattedTime: React$StatelessFunctionalComponent<
283285
DateTimeFormatOptions &
284286
CustomFormatConfig & {
285287
value: string | number | Date | void,
286288
...
287289
},
288290
>;
289-
declare export var FormattedTimeParts: React_2.FC<
291+
declare export var FormattedTimeParts: React$StatelessFunctionalComponent<
290292
FormatDateOptions & {
291293
value: $ElementType<Parameters<$PropertyType<Intl.DateTimeFormat, 'format'>>, 0> | string,
292294
children(val: Intl.DateTimeFormatPart[]): React_2.ReactElement<> | null,
@@ -325,23 +327,23 @@ declare module 'react-intl' {
325327
parts: Array<string | T>,
326328
) => R;
327329
declare export function injectIntl<IntlPropName: string, P: WrappedComponentProps<IntlPropName>>(
328-
WrappedComponent: React_2.ComponentType<P>,
330+
WrappedComponent: React$ComponentType<P>,
329331
options?: Opts<IntlPropName, false>,
330-
): React_2.FC<WithIntlProps<P>> & {
331-
WrappedComponent: React_2.ComponentType<P>,
332+
): React$StatelessFunctionalComponent<WithIntlProps<P>> & {
333+
WrappedComponent: React$ComponentType<P>,
332334
...
333335
};
334336
declare export function injectIntl<
335337
IntlPropName: string,
336338
P: WrappedComponentProps<IntlPropName>,
337-
T: React_2.ComponentType<P>,
339+
T: React$ComponentType<P>,
338340
>(
339-
WrappedComponent: React_2.ComponentType<P>,
341+
WrappedComponent: React$ComponentType<P>,
340342
options?: Opts<IntlPropName, true>,
341343
): React_2.ForwardRefExoticComponent<
342344
React_2.PropsWithoutRef<WithIntlProps<React_2.PropsWithChildren<P>>> & React_2.RefAttributes<T>,
343345
> & {
344-
WrappedComponent: React_2.ComponentType<P>,
346+
WrappedComponent: React$ComponentType<P>,
345347
...
346348
};
347349
declare export interface IntlCache {
@@ -357,7 +359,7 @@ declare module 'react-intl' {
357359
locale: string;
358360
timeZone?: string;
359361
formats: CustomFormats;
360-
textComponent?: React_2.ComponentType<> | $Keys<React_2.ReactHTML>;
362+
textComponent?: React$ComponentType<> | $Keys<React_2.ReactHTML>;
361363
messages: { [key: string]: string, ... } | { [key: string]: MessageFormatElement[], ... };
362364
defaultLocale: string;
363365
defaultFormats: CustomFormats;
@@ -372,8 +374,8 @@ declare module 'react-intl' {
372374
| FormatError,
373375
): void;
374376
}
375-
declare export var IntlContext: React_2.Context<IntlShape>;
376-
declare export interface IntlFormatters<T = React_2.Node, R = T> {
377+
declare export var IntlContext: React$Context<IntlShape>;
378+
declare export interface IntlFormatters<T = React$Node, R = T> {
377379
formatDate(
378380
value: $ElementType<Parameters<$PropertyType<Intl.DateTimeFormat, 'format'>>, 0> | string,
379381
opts?: FormatDateOptions,
@@ -417,10 +419,10 @@ declare module 'react-intl' {
417419
descriptor: MessageDescriptor,
418420
// The `+` was added to make the properties covariant rather
419421
// than invariant, something TypeScript can't do.
420-
values?: { +[key: string]: PrimitiveType | React_2.Node | FormatXMLElementFn<T, R>, ... },
422+
values?: { +[key: string]: PrimitiveType | React$Node | FormatXMLElementFn<T, R>, ... },
421423
): React$Node;
422424
formatList(values: Array<string>, opts?: FormatListOptions): string;
423-
formatList(values: Array<string | React_2.Node>, opts?: FormatListOptions): React_2.Node;
425+
formatList(values: Array<string | React$Node>, opts?: FormatListOptions): React$Node;
424426
formatDisplayName(
425427
value: $ElementType<Parameters<$PropertyType<DisplayNames, 'of'>>, 0>,
426428
opts?: FormatDisplayNameOptions,
@@ -567,7 +569,8 @@ declare module 'react-intl' {
567569
};
568570
}
569571
declare export class IntlProvider
570-
mixins React_2.PureComponent<React_2.PropsWithChildren<OptionalIntlConfig>, State> {
572+
// Changed `mixins` to `extends` in TS to Flow translation
573+
extends React$PureComponent<React_2.PropsWithChildren<OptionalIntlConfig>, State> {
571574
static displayName: string;
572575
static defaultProps: Pick<
573576
IntlConfig,
@@ -840,19 +843,19 @@ declare module 'react-intl' {
840843
declare type Props_2 = {
841844
value: number,
842845
intl: IntlShape,
843-
other: React_2.Node,
844-
zero?: React_2.Node,
845-
one?: React_2.Node,
846-
two?: React_2.Node,
847-
few?: React_2.Node,
848-
many?: React_2.Node,
849-
children?: (value: React_2.Node) => React_2.ReactElement<> | null,
846+
other: React$Node,
847+
zero?: React$Node,
848+
one?: React$Node,
849+
two?: React$Node,
850+
few?: React$Node,
851+
many?: React$Node,
852+
children?: (value: React$Node) => React_2.ReactElement<> | null,
850853
...
851854
} & FormatPluralOptions;
852-
declare type Props_3<V: { [key: string]: any, ... } = { [key: string]: React_2.Node, ... }> = {
855+
declare type Props_3<V: { [key: string]: any, ... } = { [key: string]: React$Node, ... }> = {
853856
values?: V,
854857
tagName?: React_2.ElementType<any>,
855-
children?: (...nodes: React_2.ReactNodeArray) => React_2.Node,
858+
children?: (...nodes: React_2.ReactNodeArray) => React$Node,
856859
...
857860
} & MessageDescriptor;
858861
declare export var RawIntlProvider: React_2.Provider<IntlShape>;

0 commit comments

Comments
 (0)