Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/lib/esnext.temporal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare namespace Temporal {
type InstantLike = Instant | ZonedDateTime | string;
type PlainDateLike = PlainDate | ZonedDateTime | PlainDateTime | DateLikeObject | string;
type PlainDateTimeLike = PlainDateTime | ZonedDateTime | PlainDate | DateTimeLikeObject | string;
type PlainMonthDayLike = PlainMonthDay | MonthDayLikeObject | string;
type PlainMonthDayLike = PlainMonthDay | DateLikeObject | string;
type PlainTimeLike = PlainTime | PlainDateTime | ZonedDateTime | TimeLikeObject | string;
type PlainYearMonthLike = PlainYearMonth | YearMonthLikeObject | string;
type TimeZoneLike = ZonedDateTime | string;
Expand Down Expand Up @@ -43,8 +43,6 @@ declare namespace Temporal {
nanoseconds?: number | undefined;
}

interface MonthDayLikeObject extends Omit<DateLikeObject, "era" | "eraYear"> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think it'd be good to leave this type and just assign it to DateLikeObject. Then, if a future TS manages to describe the complexity of Temporal's types then existing users who've imported MonthDayLikeObject will automatically pick up the more accurate rules.

Copy link
Member

@jakebailey jakebailey Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that possible without a break? This is an interface type, so at most we can add more properties to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, good point. In that case, then this change is fine.


interface TimeLikeObject {
hour?: number | undefined;
minute?: number | undefined;
Expand Down Expand Up @@ -438,7 +436,7 @@ declare namespace Temporal {
readonly calendarId: string;
readonly monthCode: string;
readonly day: number;
with(monthDayLike: PartialTemporalLike<MonthDayLikeObject>, options?: OverflowOptions): PlainMonthDay;
with(monthDayLike: PartialTemporalLike<DateLikeObject>, options?: OverflowOptions): PlainMonthDay;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per comment above, I wouldn't change this.

equals(other: PlainMonthDayLike): boolean;
toString(options?: PlainDateToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
Expand Down
8 changes: 5 additions & 3 deletions tests/baselines/reference/temporal.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
temporal.ts(25,13): error TS2339: Property 'year' does not exist on type 'Instant'.
temporal.ts(1502,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
temporal.ts(1512,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
temporal.ts(1518,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
temporal.ts(1504,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
temporal.ts(1514,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
temporal.ts(1520,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.


==== temporal.ts (4 errors) ====
Expand Down Expand Up @@ -1503,6 +1503,8 @@ temporal.ts(1518,8): error TS2339: Property 'month' does not exist on type 'Plai
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
// => throws (either year or monthCode is required)
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");
Expand Down
4 changes: 4 additions & 0 deletions tests/baselines/reference/temporal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,8 @@
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
// => throws (either year or monthCode is required)
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");
Expand Down Expand Up @@ -3099,6 +3101,8 @@
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
// => 1970-02-21[u-ca=hebrew]
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
// => throws (either year or monthCode is required)
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");
Expand Down
Loading