File tree Expand file tree Collapse file tree 2 files changed +61
-10
lines changed Expand file tree Collapse file tree 2 files changed +61
-10
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,28 @@ declare namespace Intl {
46
46
| "second" | "seconds"
47
47
;
48
48
49
+ /**
50
+ * Value of the `unit` property in objects returned by
51
+ * `Intl.RelativeTimeFormat.prototype.formatToParts()`. `formatToParts` and
52
+ * `format` methods accept either singular or plural unit names as input,
53
+ * but `formatToParts` only outputs singular (e.g. "day") not plural (e.g.
54
+ * "days").
55
+ *
56
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
57
+ *
58
+ * [Specification](https://tc39.es/ecma402/#sec-singularrelativetimeunit).
59
+ */
60
+ type RelativeTimeFormatUnitSingular =
61
+ | "year"
62
+ | "quarter"
63
+ | "month"
64
+ | "week"
65
+ | "day"
66
+ | "hour"
67
+ | "minute"
68
+ | "second"
69
+ ;
70
+
49
71
/**
50
72
* The locale matching algorithm to use.
51
73
*
@@ -111,11 +133,16 @@ declare namespace Intl {
111
133
*
112
134
* [Specification](https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts).
113
135
*/
114
- interface RelativeTimeFormatPart {
115
- type : string ;
116
- value : string ;
117
- unit ?: RelativeTimeFormatUnit ;
118
- }
136
+ type RelativeTimeFormatPart =
137
+ | {
138
+ type : "literal" ;
139
+ value : string ;
140
+ }
141
+ | {
142
+ type : Exclude < NumberFormatPartTypes , "literal" > ;
143
+ value : string ;
144
+ unit : RelativeTimeFormatUnitSingular ;
145
+ } ;
119
146
120
147
interface RelativeTimeFormat {
121
148
/**
Original file line number Diff line number Diff line change @@ -30,6 +30,25 @@ declare namespace Intl {
30
30
| "second"
31
31
| "seconds" ;
32
32
33
+ /**
34
+ * Value of the `unit` property in objects returned by
35
+ * `Intl.RelativeTimeFormat.prototype.formatToParts()`. `formatToParts` and
36
+ * `format` methods accept either singular or plural unit names as input,
37
+ * but `formatToParts` only outputs singular (e.g. "day") not plural (e.g.
38
+ * "days").
39
+ *
40
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
41
+ */
42
+ type RelativeTimeFormatUnitSingular =
43
+ | "year"
44
+ | "quarter"
45
+ | "month"
46
+ | "week"
47
+ | "day"
48
+ | "hour"
49
+ | "minute"
50
+ | "second" ;
51
+
33
52
/**
34
53
* The locale matching algorithm to use.
35
54
*
@@ -93,11 +112,16 @@ declare namespace Intl {
93
112
*
94
113
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
95
114
*/
96
- interface RelativeTimeFormatPart {
97
- type : string ;
98
- value : string ;
99
- unit ?: RelativeTimeFormatUnit ;
100
- }
115
+ type RelativeTimeFormatPart =
116
+ | {
117
+ type : "literal" ;
118
+ value : string ;
119
+ }
120
+ | {
121
+ type : Exclude < NumberFormatPartTypes , "literal" > ;
122
+ value : string ;
123
+ unit : RelativeTimeFormatUnitSingular ;
124
+ } ;
101
125
102
126
interface RelativeTimeFormat {
103
127
/**
You can’t perform that action at this time.
0 commit comments