forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathes2025.intl.d.ts
More file actions
185 lines (172 loc) · 7.97 KB
/
es2025.intl.d.ts
File metadata and controls
185 lines (172 loc) · 7.97 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
declare namespace Intl {
type DurationTimeFormatLocaleMatcher = "lookup" | "best fit";
/**
* Value of the `unit` property in duration objects
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration).
*/
type DurationTimeFormatUnit =
| "years"
| "months"
| "weeks"
| "days"
| "hours"
| "minutes"
| "seconds"
| "milliseconds"
| "microseconds"
| "nanoseconds";
/**
* The style of the formatted duration.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style).
*/
type DurationFormatStyle = "long" | "short" | "narrow" | "digital";
type DurationFormatUnitSingular =
| "year"
| "quarter"
| "month"
| "week"
| "day"
| "hour"
| "minute"
| "second";
/**
* An object representing the relative time format in parts
* that can be used for custom locale-aware formatting.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts#examples).
*/
type DurationFormatPart =
| {
type: "literal";
value: string;
}
| {
type: Exclude<NumberFormatPartTypes, "literal">;
value: string;
unit: DurationFormatUnitSingular;
};
type DurationFormatOption =
| "long"
| "short"
| "narrow"
| "numeric"
| "2-digit";
type DurationFormatDisplayOption = "always" | "auto";
/**
* Number of how many fractional second digits to display in the output.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#fractionaldigits).
*/
type fractionalDigitsOption = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
interface ResolvedDurationFormatOptions {
locale?: UnicodeBCP47LocaleIdentifier;
numberingSystem?: DateTimeFormatOptions["numberingSystem"];
style?: DurationFormatStyle;
years?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
yearsDisplay?: DurationFormatDisplayOption;
months?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
monthsDisplay?: DurationFormatDisplayOption;
weeks?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
weeksDisplay?: DurationFormatDisplayOption;
days?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
daysDisplay?: DurationFormatDisplayOption;
hours?: DurationFormatOptions;
hoursDisplay?: DurationFormatDisplayOption;
minutes?: DurationFormatOptions;
minutesDisplay?: DurationFormatDisplayOption;
seconds?: DurationFormatOptions;
secondsDisplay?: DurationFormatDisplayOption;
milliseconds?: DurationFormatOptions;
millisecondsDisplay?: DurationFormatDisplayOption;
microseconds?: DurationFormatOptions;
microsecondsDisplay?: DurationFormatDisplayOption;
nanoseconds?: DurationFormatOptions;
nanosecondsDisplay?: DurationFormatDisplayOption;
fractionalDigits?: fractionalDigitsOption;
}
interface DurationFormatOptions {
localeMatcher?: DurationTimeFormatLocaleMatcher;
numberingSystem?: DateTimeFormatOptions["numberingSystem"];
style?: DurationFormatStyle;
years?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
yearsDisplay?: DurationFormatDisplayOption;
months?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
monthsDisplay?: DurationFormatDisplayOption;
weeks?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
weeksDisplay?: DurationFormatDisplayOption;
days?: Exclude<DurationFormatOption, "numeric" | "2-digit">;
daysDisplay?: DurationFormatDisplayOption;
hours?: DurationFormatOption;
hoursDisplay?: DurationFormatDisplayOption;
minutes?: DurationFormatOption;
minutesDisplay?: DurationFormatDisplayOption;
seconds?: DurationFormatOption;
secondsDisplay?: DurationFormatDisplayOption;
milliseconds?: DurationFormatOption;
millisecondsDisplay?: DurationFormatDisplayOption;
microseconds?: DurationFormatOption;
microsecondsDisplay?: DurationFormatDisplayOption;
nanoseconds?: DurationFormatOption;
nanosecondsDisplay?: DurationFormatDisplayOption;
fractionalDigits?: fractionalDigitsOption;
}
/**
* The duration object to be formatted
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration).
*/
type DurationType = Partial<Record<DurationTimeFormatUnit, number>>;
interface DurationFormat {
/**
* @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format).
*/
format(duration: DurationType): string;
/**
* @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts).
*/
formatToParts(duration: DurationType): DurationFormatPart[];
/**
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions).
*/
resolvedOptions(): ResolvedDurationFormatOptions;
}
const DurationFormat: {
prototype: DurationFormat;
/**
* @param locales A string with a BCP 47 language tag, or an array of such strings.
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
* page.
*
* @param options An object for setting up a duration format.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat).
*/
new (
locales?: LocalesArgument,
options?: DurationFormatOptions,
): DurationFormat;
/**
* Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale.
*
* @param locales A string with a BCP 47 language tag, or an array of such strings.
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
* page.
*
* @param options An object with a locale matcher.
*
* @returns An array of strings representing a subset of the given locale tags that are supported in display names without having to fall back to the runtime's default locale.
*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf).
*/
supportedLocalesOf(
locales?: LocalesArgument,
options?: { localeMatcher?: DurationTimeFormatLocaleMatcher; },
): UnicodeBCP47LocaleIdentifier[];
};
}