-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
react-intl.d.ts
57 lines (51 loc) · 1.78 KB
/
react-intl.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
declare module "react-intl" {
import { OptionalIntlConfig } from "react-intl/dist/components/provider";
import * as ReactIntl from "node_modules/react-intl";
export * from "node_modules/react-intl";
export interface MessageDescriptor {
description?: string;
defaultMessage: string;
id?: string;
}
type Messages<Names extends keyof any = string> = Record<
Names,
MessageDescriptor
>;
type PrimitiveType = string | number | boolean | null | undefined | Date;
type FormatXMLElementFn = (...args: any[]) => string | {};
export interface IntlFormatters
extends Omit<ReactIntl.IntlFormatters, "formatMessage"> {
formatMessage(
descriptor: MessageDescriptor,
values?: Record<string, PrimitiveType>
): string;
formatMessage(
descriptor: MessageDescriptor,
values?: Record<
string,
PrimitiveType | React.ReactElement | FormatXMLElementFn
>
): string | React.ReactNodeArray;
}
export interface FormattedMessageProps<
V extends Record<string, any> = Record<string, React.ReactNode>
> extends MessageDescriptor {
values?: V;
tagName?: React.ElementType<any>;
children?(...nodes: React.ReactNodeArray): React.ReactNode;
}
export function defineMessages<Names extends keyof any>(
messageDescriptors: Messages<Names>
): Messages<Names>;
export interface IntlShape extends ReactIntl.IntlConfig, IntlFormatters {
formatters: ReactIntl.Formatters;
}
export class FormattedMessage<
TValues extends Record<string, any> = Record<
string,
PrimitiveType | React.ReactElement | FormatXMLElementFn
>
> extends React.Component<FormattedMessageProps<TValues>> {}
export function useIntl(): IntlShape;
export function createIntl(config: OptionalIntlConfig): IntlShape;
}