Skip to content

Commit 56b991f

Browse files
committed
small bikesheds
1 parent 8062a7d commit 56b991f

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

src/lib/esnext.temporal.d.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ declare namespace Temporal {
6363
type DateUnit = "year" | "month" | "week" | "day" | "years" | "months" | "weeks" | "days";
6464
type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds";
6565

66+
interface DisambiguationOptions {
67+
disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
68+
}
69+
6670
interface OverflowOptions {
6771
overflow?: "constrain" | "reject" | undefined;
6872
}
6973

74+
interface TransitionOptions {
75+
direction: "next" | "previous";
76+
}
77+
7078
interface RoundingOptions<Units extends DateUnit | TimeUnit> {
7179
smallestUnit?: Units | undefined;
7280
roundingIncrement?: number | undefined;
@@ -179,8 +187,6 @@ declare namespace Temporal {
179187

180188
interface PlainDateTimeToStringOptions extends PlainDateToStringOptions, PlainTimeToStringOptions {}
181189

182-
interface PlainDateTimeToZonedDateTimeOptions extends Pick<ZonedDateTimeToZonedDateTimeOptions, "disambiguation"> {}
183-
184190
interface PlainDateTime {
185191
readonly calendarId: string;
186192
readonly era: string | undefined;
@@ -218,7 +224,7 @@ declare namespace Temporal {
218224
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
219225
toJSON(): string;
220226
valueOf(): never;
221-
toZonedDateTime(timeZone: TimeZoneLike, options?: PlainDateTimeToZonedDateTimeOptions): ZonedDateTime;
227+
toZonedDateTime(timeZone: TimeZoneLike, options?: DisambiguationOptions): ZonedDateTime;
222228
toPlainDate(): PlainDate;
223229
toPlainTime(): PlainTime;
224230
readonly [Symbol.toStringTag]: "Temporal.PlainDateTime";
@@ -237,15 +243,10 @@ declare namespace Temporal {
237243
timeZoneName?: "auto" | "never" | "critical" | undefined;
238244
}
239245

240-
interface ZonedDateTimeToZonedDateTimeOptions extends OverflowOptions {
241-
disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
246+
interface ZonedDateTimeFromOptions extends OverflowOptions, DisambiguationOptions {
242247
offset?: "use" | "ignore" | "prefer" | "reject" | undefined;
243248
}
244249

245-
interface ZonedDateTimeTransitionOptions {
246-
direction: "next" | "previous";
247-
}
248-
249250
interface ZonedDateTime {
250251
readonly calendarId: string;
251252
readonly timeZoneId: string;
@@ -275,7 +276,7 @@ declare namespace Temporal {
275276
readonly inLeapYear: boolean;
276277
readonly offsetNanoseconds: number;
277278
readonly offset: string;
278-
with(zonedDateTimeLike: PartialTemporalLike<ZonedDateTimeLikeObject>, options?: ZonedDateTimeToZonedDateTimeOptions): ZonedDateTime;
279+
with(zonedDateTimeLike: PartialTemporalLike<ZonedDateTimeLikeObject>, options?: ZonedDateTimeFromOptions): ZonedDateTime;
279280
withPlainTime(plainTime?: PlainTimeLike): ZonedDateTime;
280281
withTimeZone(timeZone: TimeZoneLike): ZonedDateTime;
281282
withCalendar(calendar: CalendarLike): ZonedDateTime;
@@ -292,7 +293,7 @@ declare namespace Temporal {
292293
valueOf(): never;
293294
startOfDay(): ZonedDateTime;
294295
getTimeZoneTransition(direction: "next" | "previous"): ZonedDateTime | null;
295-
getTimeZoneTransition(direction: ZonedDateTimeTransitionOptions): ZonedDateTime | null;
296+
getTimeZoneTransition(direction: TransitionOptions): ZonedDateTime | null;
296297
toInstant(): Instant;
297298
toPlainDate(): PlainDate;
298299
toPlainTime(): PlainTime;
@@ -303,7 +304,7 @@ declare namespace Temporal {
303304
interface ZonedDateTimeConstructor {
304305
new (epochNanoseconds: bigint, timeZone: string, calendar?: string): ZonedDateTime;
305306
readonly prototype: ZonedDateTime;
306-
from(item: ZonedDateTimeLike, options?: ZonedDateTimeToZonedDateTimeOptions): ZonedDateTime;
307+
from(item: ZonedDateTimeLike, options?: ZonedDateTimeFromOptions): ZonedDateTime;
307308
compare(one: ZonedDateTimeLike, two: ZonedDateTimeLike): number;
308309
}
309310
var ZonedDateTime: ZonedDateTimeConstructor;
@@ -393,8 +394,6 @@ declare namespace Temporal {
393394
day: number;
394395
}
395396

396-
interface PlainYearMonthToStringOptions extends Pick<PlainDateToStringOptions, "calendarName"> {}
397-
398397
interface PlainYearMonth {
399398
readonly calendarId: string;
400399
readonly era: string | undefined;
@@ -412,7 +411,7 @@ declare namespace Temporal {
412411
until(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): Duration;
413412
since(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): Duration;
414413
equals(other: PlainYearMonthLike): boolean;
415-
toString(options?: PlainYearMonthToStringOptions): string;
414+
toString(options?: PlainDateToStringOptions): string;
416415
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
417416
toJSON(): string;
418417
valueOf(): never;
@@ -432,15 +431,13 @@ declare namespace Temporal {
432431
year: number;
433432
}
434433

435-
interface PlainMonthDayToStringOptions extends Pick<PlainDateTimeToStringOptions, "calendarName"> {}
436-
437434
interface PlainMonthDay {
438435
readonly calendarId: string;
439436
readonly monthCode: string;
440437
readonly day: number;
441438
with(monthDayLike: PartialTemporalLike<MonthDayLikeObject>, options?: OverflowOptions): PlainMonthDay;
442439
equals(other: PlainMonthDayLike): boolean;
443-
toString(options?: PlainMonthDayToStringOptions): string;
440+
toString(options?: PlainDateToStringOptions): string;
444441
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
445442
toJSON(): string;
446443
valueOf(): never;

0 commit comments

Comments
 (0)