@@ -59,8 +59,22 @@ declare namespace Temporal {
5959 offset ?: string | undefined ;
6060 }
6161
62- type DateUnit = "year" | "month" | "week" | "day" | "years" | "months" | "weeks" | "days" ;
63- type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds" ;
62+ type DateUnit = "year" | "month" | "week" | "day" ;
63+ type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond" ;
64+ type PluralizeUnit < T extends DateUnit | TimeUnit > =
65+ | T
66+ | {
67+ year : "years" ;
68+ month : "months" ;
69+ week : "weeks" ;
70+ day : "days" ;
71+ hour : "hours" ;
72+ minute : "minutes" ;
73+ second : "seconds" ;
74+ millisecond : "milliseconds" ;
75+ microsecond : "microseconds" ;
76+ nanosecond : "nanoseconds" ;
77+ } [ T ] ;
6478
6579 interface DisambiguationOptions {
6680 disambiguation ?: "compatible" | "earlier" | "later" | "reject" | undefined ;
@@ -75,13 +89,13 @@ declare namespace Temporal {
7589 }
7690
7791 interface RoundingOptions < Units extends DateUnit | TimeUnit > {
78- smallestUnit ?: Units | undefined ;
92+ smallestUnit ?: PluralizeUnit < Units > | undefined ;
7993 roundingIncrement ?: number | undefined ;
8094 roundingMode ?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined ;
8195 }
8296
8397 interface RoundingOptionsWithLargestUnit < Units extends DateUnit | TimeUnit > extends RoundingOptions < Units > {
84- largestUnit ?: "auto" | Units | undefined ;
98+ largestUnit ?: "auto" | PluralizeUnit < Units > | undefined ;
8599 }
86100
87101 interface ToStringRoundingOptions < Units extends DateUnit | TimeUnit > extends Pick < RoundingOptions < Units > , "smallestUnit" | "roundingMode" > { }
@@ -152,7 +166,7 @@ declare namespace Temporal {
152166 }
153167 var PlainDate : PlainDateConstructor ;
154168
155- interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds < Exclude < TimeUnit , "hour" | "hours" > > { }
169+ interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds < Exclude < TimeUnit , "hour" > > { }
156170
157171 interface PlainTime {
158172 readonly hour : number ;
@@ -167,7 +181,7 @@ declare namespace Temporal {
167181 until ( other : PlainTimeLike , options ?: RoundingOptionsWithLargestUnit < TimeUnit > ) : Duration ;
168182 since ( other : PlainTimeLike , options ?: RoundingOptionsWithLargestUnit < TimeUnit > ) : Duration ;
169183 equals ( other : PlainTimeLike ) : boolean ;
170- round ( roundTo : TimeUnit ) : PlainTime ;
184+ round ( roundTo : PluralizeUnit < TimeUnit > ) : PlainTime ;
171185 round ( roundTo : RoundingOptions < TimeUnit > ) : PlainTime ;
172186 toString ( options ?: PlainTimeToStringOptions ) : string ;
173187 toLocaleString ( locales ?: Intl . LocalesArgument , options ?: Intl . DateTimeFormatOptions ) : string ;
@@ -216,8 +230,8 @@ declare namespace Temporal {
216230 subtract ( duration : DurationLike , options ?: OverflowOptions ) : PlainDateTime ;
217231 until ( other : PlainDateTimeLike , options ?: RoundingOptionsWithLargestUnit < DateUnit | TimeUnit > ) : Duration ;
218232 since ( other : PlainDateTimeLike , options ?: RoundingOptionsWithLargestUnit < DateUnit | TimeUnit > ) : Duration ;
219- round ( roundTo : "day" | "days" | TimeUnit ) : PlainDateTime ;
220- round ( roundTo : RoundingOptions < "day" | "days" | TimeUnit > ) : PlainDateTime ;
233+ round ( roundTo : PluralizeUnit < "day" | TimeUnit > ) : PlainDateTime ;
234+ round ( roundTo : RoundingOptions < "day" | TimeUnit > ) : PlainDateTime ;
221235 equals ( other : PlainDateTimeLike ) : boolean ;
222236 toString ( options ?: PlainDateTimeToStringOptions ) : string ;
223237 toLocaleString ( locales ?: Intl . LocalesArgument , options ?: Intl . DateTimeFormatOptions ) : string ;
@@ -283,8 +297,8 @@ declare namespace Temporal {
283297 subtract ( duration : DurationLike , options ?: OverflowOptions ) : ZonedDateTime ;
284298 until ( other : ZonedDateTimeLike , options ?: RoundingOptionsWithLargestUnit < DateUnit | TimeUnit > ) : Duration ;
285299 since ( other : ZonedDateTimeLike , options ?: RoundingOptionsWithLargestUnit < DateUnit | TimeUnit > ) : Duration ;
286- round ( roundTo : "day" | "days" | TimeUnit ) : ZonedDateTime ;
287- round ( roundTo : RoundingOptions < "day" | "days" | TimeUnit > ) : ZonedDateTime ;
300+ round ( roundTo : PluralizeUnit < "day" | TimeUnit > ) : ZonedDateTime ;
301+ round ( roundTo : RoundingOptions < "day" | TimeUnit > ) : ZonedDateTime ;
288302 equals ( other : ZonedDateTimeLike ) : boolean ;
289303 toString ( options ?: ZonedDateTimeToStringOptions ) : string ;
290304 toLocaleString ( locales ?: Intl . LocalesArgument , options ?: Intl . DateTimeFormatOptions ) : string ;
@@ -314,10 +328,10 @@ declare namespace Temporal {
314328
315329 interface DurationRoundingOptions extends DurationRelativeToOptions , RoundingOptionsWithLargestUnit < DateUnit | TimeUnit > { }
316330
317- interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds < Exclude < TimeUnit , "hour" | "minute" | "hours" | "minutes" > > { }
331+ interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds < Exclude < TimeUnit , "hour" | "minute" > > { }
318332
319333 interface DurationTotalOptions extends DurationRelativeToOptions {
320- unit : DateUnit | TimeUnit ;
334+ unit : PluralizeUnit < DateUnit | TimeUnit > ;
321335 }
322336
323337 interface Duration {
@@ -338,9 +352,9 @@ declare namespace Temporal {
338352 abs ( ) : Duration ;
339353 add ( other : DurationLike ) : Duration ;
340354 subtract ( other : DurationLike ) : Duration ;
341- round ( roundTo : "day" | "days" | TimeUnit ) : Duration ;
355+ round ( roundTo : PluralizeUnit < "day" | TimeUnit > ) : Duration ;
342356 round ( roundTo : DurationRoundingOptions ) : Duration ;
343- total ( totalOf : "day" | "days" | TimeUnit ) : number ;
357+ total ( totalOf : PluralizeUnit < "day" | TimeUnit > ) : number ;
344358 total ( totalOf : DurationTotalOptions ) : number ;
345359 toString ( options ?: DurationToStringOptions ) : string ;
346360 toLocaleString ( locales ?: Intl . LocalesArgument , options ?: Intl . DurationFormatOptions ) : string ;
@@ -368,7 +382,7 @@ declare namespace Temporal {
368382 subtract ( duration : DurationLike ) : Instant ;
369383 until ( other : InstantLike , options ?: RoundingOptionsWithLargestUnit < TimeUnit > ) : Duration ;
370384 since ( other : InstantLike , options ?: RoundingOptionsWithLargestUnit < TimeUnit > ) : Duration ;
371- round ( roundTo : TimeUnit ) : Instant ;
385+ round ( roundTo : PluralizeUnit < TimeUnit > ) : Instant ;
372386 round ( roundTo : RoundingOptions < TimeUnit > ) : Instant ;
373387 equals ( other : InstantLike ) : boolean ;
374388 toString ( options ?: InstantToStringOptions ) : string ;
@@ -407,8 +421,8 @@ declare namespace Temporal {
407421 with ( yearMonthLike : PartialTemporalLike < YearMonthLikeObject > , options ?: OverflowOptions ) : PlainYearMonth ;
408422 add ( duration : DurationLike , options ?: OverflowOptions ) : PlainYearMonth ;
409423 subtract ( duration : DurationLike , options ?: OverflowOptions ) : PlainYearMonth ;
410- until ( other : PlainYearMonthLike , options ?: RoundingOptionsWithLargestUnit < "year" | "month" | "years" | "months" > ) : Duration ;
411- since ( other : PlainYearMonthLike , options ?: RoundingOptionsWithLargestUnit < "year" | "month" | "years" | "months" > ) : Duration ;
424+ until ( other : PlainYearMonthLike , options ?: RoundingOptionsWithLargestUnit < "year" | "month" > ) : Duration ;
425+ since ( other : PlainYearMonthLike , options ?: RoundingOptionsWithLargestUnit < "year" | "month" > ) : Duration ;
412426 equals ( other : PlainYearMonthLike ) : boolean ;
413427 toString ( options ?: PlainDateToStringOptions ) : string ;
414428 toLocaleString ( locales ?: Intl . LocalesArgument , options ?: Intl . DateTimeFormatOptions ) : string ;
0 commit comments