1
1
declare namespace Intl {
2
-
3
2
/**
4
3
* [Unicode BCP 47 Locale Identifiers](https://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers) definition.
5
4
*
@@ -16,15 +15,22 @@ declare namespace Intl {
16
15
* [Specification](https://tc39.es/ecma402/#sec-singularrelativetimeunit).
17
16
*/
18
17
type RelativeTimeFormatUnit =
19
- | "year" | "years"
20
- | "quarter" | "quarters"
21
- | "month" | "months"
22
- | "week" | "weeks"
23
- | "day" | "days"
24
- | "hour" | "hours"
25
- | "minute" | "minutes"
26
- | "second" | "seconds"
27
- ;
18
+ | "year"
19
+ | "years"
20
+ | "quarter"
21
+ | "quarters"
22
+ | "month"
23
+ | "months"
24
+ | "week"
25
+ | "weeks"
26
+ | "day"
27
+ | "days"
28
+ | "hour"
29
+ | "hours"
30
+ | "minute"
31
+ | "minutes"
32
+ | "second"
33
+ | "seconds" ;
28
34
29
35
/**
30
36
* The locale matching algorithm to use.
@@ -127,10 +133,7 @@ declare namespace Intl {
127
133
*
128
134
* [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format).
129
135
*/
130
- format (
131
- value : number ,
132
- unit : RelativeTimeFormatUnit ,
133
- ) : string ;
136
+ format ( value : number , unit : RelativeTimeFormatUnit ) : string ;
134
137
135
138
/**
136
139
* A version of the format method which it returns an array of objects
@@ -162,7 +165,7 @@ declare namespace Intl {
162
165
*/
163
166
formatToParts (
164
167
value : number ,
165
- unit : RelativeTimeFormatUnit ,
168
+ unit : RelativeTimeFormatUnit
166
169
) : RelativeTimeFormatPart [ ] ;
167
170
168
171
/**
@@ -219,9 +222,11 @@ declare namespace Intl {
219
222
*
220
223
* [Specification](https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor).
221
224
*/
222
- new (
223
- locales ?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier [ ] ,
224
- options ?: RelativeTimeFormatOptions ,
225
+ new (
226
+ locales ?:
227
+ | UnicodeBCP47LocaleIdentifier
228
+ | UnicodeBCP47LocaleIdentifier [ ] ,
229
+ options ?: RelativeTimeFormatOptions
225
230
) : RelativeTimeFormat ;
226
231
227
232
/**
@@ -256,34 +261,80 @@ declare namespace Intl {
256
261
* [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf).
257
262
*/
258
263
supportedLocalesOf (
259
- locales ?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier [ ] ,
260
- options ?: RelativeTimeFormatOptions ,
264
+ locales ?:
265
+ | UnicodeBCP47LocaleIdentifier
266
+ | UnicodeBCP47LocaleIdentifier [ ] ,
267
+ options ?: RelativeTimeFormatOptions
261
268
) : UnicodeBCP47LocaleIdentifier [ ] ;
262
269
} ;
263
270
271
+ /**
272
+ * List of sanctioned unit: https://402.ecma-international.org/7.0/#table-sanctioned-simple-unit-identifiers
273
+ */
274
+ type NumberFormatUnit =
275
+ | "degree"
276
+ | "acre"
277
+ | "hectare"
278
+ | "percent"
279
+ | "bit"
280
+ | "byte"
281
+ | "gigabit"
282
+ | "gigabyte"
283
+ | "kilobit"
284
+ | "kilobyte"
285
+ | "megabit"
286
+ | "megabyte"
287
+ | "petabyte"
288
+ | "terabit"
289
+ | "terabyte"
290
+ | "day"
291
+ | "hour"
292
+ | "millisecond"
293
+ | "minute"
294
+ | "month"
295
+ | "second"
296
+ | "week"
297
+ | "year"
298
+ | "centimeter"
299
+ | "foot"
300
+ | "inch"
301
+ | "kilometer"
302
+ | "meter"
303
+ | "mile-scandinavian"
304
+ | "mile"
305
+ | "millimeter"
306
+ | "yard"
307
+ | "gram"
308
+ | "kilogram"
309
+ | "ounce"
310
+ | "pound"
311
+ | "stone"
312
+ | "celsius"
313
+ | "fahrenheit"
314
+ | "fluid-ounce"
315
+ | "gallon"
316
+ | "liter"
317
+ | "milliliter" ;
318
+
264
319
interface NumberFormatOptions {
265
- compactDisplay ?: string ;
266
- notation ?: string ;
267
- signDisplay ?: string ;
268
- unit ?: string ;
269
- unitDisplay ?: string ;
320
+ compactDisplay ?: "short" | "long" ;
321
+ notation ?: "standard" | "scientific" | "engineering" | "compact" ;
322
+ signDisplay ?: "auto" | "never" | "always" ;
323
+ unit ?: NumberFormatUnit ;
324
+ unitDisplay ?: "short" | "long" | "narrow" ;
270
325
}
271
326
272
327
interface ResolvedNumberFormatOptions {
273
- compactDisplay ?: string ;
274
- notation ?: string ;
275
- signDisplay ?: string ;
276
- unit ?: string ;
277
- unitDisplay ?: string ;
328
+ compactDisplay ?: "short" | "long" ;
329
+ notation ?: "standard" | "scientific" | "engineering" | "compact" ;
330
+ signDisplay ?: "auto" | "never" | "always" ;
331
+ unit ?: NumberFormatUnit ;
332
+ unitDisplay ?: "short" | "long" | "narrow" ;
278
333
}
279
334
280
335
interface DateTimeFormatOptions {
281
- dateStyle ?: "full" | "long" | "medium" | "short" ;
282
- timeStyle ?: "full" | "long" | "medium" | "short" ;
283
336
calendar ?: string ;
284
- dayPeriod ?: "narrow" | "short" | "long" ;
285
337
numberingSystem ?: string ;
286
338
hourCycle ?: "h11" | "h12" | "h23" | "h24" ;
287
- fractionalSecondDigits ?: 0 | 1 | 2 | 3 ;
288
339
}
289
340
}
0 commit comments