|
1 | 1 | type t
|
2 | 2 |
|
| 3 | +type numeric = [#always | #auto] |
| 4 | +type style = [#long | #short | #narrow] |
| 5 | +type timeUnit = [#year | #quarter | #month | #week | #day | #hour | #minute | #second] |
| 6 | + |
| 7 | +type options = { |
| 8 | + localeMatcher?: Core__Intl__Common.localeMatcher, |
| 9 | + numeric?: numeric, |
| 10 | + style?: style, |
| 11 | +} |
| 12 | + |
| 13 | +type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} |
| 14 | + |
| 15 | +type resolvedOptions = { |
| 16 | + locale: string, |
| 17 | + numeric: numeric, |
| 18 | + style: style, |
| 19 | + numberingSystem: string, |
| 20 | +} |
| 21 | + |
| 22 | +type relativeTimePartComponent = [#literal | #integer] |
| 23 | +type relativeTimePart = { |
| 24 | + \"type": relativeTimePartComponent, |
| 25 | + value: string, |
| 26 | + unit?: timeUnit, |
| 27 | +} |
| 28 | + |
3 | 29 | @new external make: unit => t = "Intl.RelativeTimeFormat"
|
4 | 30 | @new external makeWithLocale: string => t = "Intl.RelativeTimeFormat"
|
5 | 31 | @new external makeWithLocales: array<string> => t = "Intl.RelativeTimeFormat"
|
6 |
| -@new external makeWithLocaleAndOptions: (string, {..}) => t = "Intl.RelativeTimeFormat" |
7 |
| -@new external makeWithLocalesAndOptions: (array<string>, {..}) => t = "Intl.RelativeTimeFormat" |
8 |
| -@new external makeWithOptions: (@as(json`undefined`) _, {..}) => t = "Intl.RelativeTimeFormat" |
| 32 | +@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.RelativeTimeFormat" |
| 33 | +@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.RelativeTimeFormat" |
| 34 | +@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.RelativeTimeFormat" |
9 | 35 |
|
10 | 36 | @val
|
11 | 37 | external supportedLocalesOf: array<string> => t = "Intl.RelativeTimeFormat.supportedLocalesOf"
|
12 | 38 | @val
|
13 |
| -external supportedLocalesOfWithOptions: (array<string>, {..}) => t = |
| 39 | +external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t = |
14 | 40 | "Intl.RelativeTimeFormat.supportedLocalesOf"
|
15 | 41 |
|
16 |
| -@send external resolvedOptions: t => {..} = "resolvedOptions" |
17 |
| - |
18 |
| -type timeUnit = [#year | #quarter | #month | #week | #day | #hour | #minute | #second] |
| 42 | +@send external resolvedOptions: t => resolvedOptions = "resolvedOptions" |
19 | 43 |
|
20 | 44 | @send external format: (t, int, timeUnit) => string = "format"
|
21 | 45 | @send
|
22 |
| -external formatToParts: ( |
23 |
| - t, |
24 |
| - int, |
25 |
| - timeUnit, |
26 |
| -) => array<{ |
27 |
| - "type": string, |
28 |
| - "value": string, |
29 |
| - "unit": option<string>, |
30 |
| -}> = "formatToParts" |
| 46 | +external formatToParts: (t, int, timeUnit) => array<relativeTimePart> = "formatToParts" |
0 commit comments