Skip to content

Commit 0ed1ee5

Browse files
authored
Fix from and with method types of Temporal.PlainMonthDay (#63142)
1 parent 040c208 commit 0ed1ee5

File tree

6 files changed

+377
-316
lines changed

6 files changed

+377
-316
lines changed

src/lib/esnext.temporal.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ declare namespace Temporal {
88
type InstantLike = Instant | ZonedDateTime | string;
99
type PlainDateLike = PlainDate | ZonedDateTime | PlainDateTime | DateLikeObject | string;
1010
type PlainDateTimeLike = PlainDateTime | ZonedDateTime | PlainDate | DateTimeLikeObject | string;
11-
type PlainMonthDayLike = PlainMonthDay | MonthDayLikeObject | string;
11+
type PlainMonthDayLike = PlainMonthDay | DateLikeObject | string;
1212
type PlainTimeLike = PlainTime | PlainDateTime | ZonedDateTime | TimeLikeObject | string;
1313
type PlainYearMonthLike = PlainYearMonth | YearMonthLikeObject | string;
1414
type TimeZoneLike = ZonedDateTime | string;
@@ -43,8 +43,6 @@ declare namespace Temporal {
4343
nanoseconds?: number | undefined;
4444
}
4545

46-
interface MonthDayLikeObject extends Omit<DateLikeObject, "era" | "eraYear"> {}
47-
4846
interface TimeLikeObject {
4947
hour?: number | undefined;
5048
minute?: number | undefined;
@@ -438,7 +436,7 @@ declare namespace Temporal {
438436
readonly calendarId: string;
439437
readonly monthCode: string;
440438
readonly day: number;
441-
with(monthDayLike: PartialTemporalLike<MonthDayLikeObject>, options?: OverflowOptions): PlainMonthDay;
439+
with(monthDayLike: PartialTemporalLike<DateLikeObject>, options?: OverflowOptions): PlainMonthDay;
442440
equals(other: PlainMonthDayLike): boolean;
443441
toString(options?: PlainDateToStringOptions): string;
444442
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;

tests/baselines/reference/temporal.errors.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
temporal.ts(25,13): error TS2339: Property 'year' does not exist on type 'Instant'.
2-
temporal.ts(1502,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
3-
temporal.ts(1512,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
4-
temporal.ts(1518,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
2+
temporal.ts(1504,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
3+
temporal.ts(1514,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
4+
temporal.ts(1520,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'.
55

66

77
==== temporal.ts (4 errors) ====
@@ -1503,6 +1503,8 @@ temporal.ts(1518,8): error TS2339: Property 'month' does not exist on type 'Plai
15031503
// => 1970-02-21[u-ca=hebrew]
15041504
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
15051505
// => 1970-02-21[u-ca=hebrew]
1506+
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
1507+
// => 1970-02-21[u-ca=hebrew]
15061508
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
15071509
// => throws (either year or monthCode is required)
15081510
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");

tests/baselines/reference/temporal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,8 @@
14971497
// => 1970-02-21[u-ca=hebrew]
14981498
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
14991499
// => 1970-02-21[u-ca=hebrew]
1500+
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
1501+
// => 1970-02-21[u-ca=hebrew]
15001502
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
15011503
// => throws (either year or monthCode is required)
15021504
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");
@@ -3099,6 +3101,8 @@
30993101
// => 1970-02-21[u-ca=hebrew]
31003102
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" });
31013103
// => 1970-02-21[u-ca=hebrew]
3104+
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, era: "am", eraYear: 5779, calendar: "hebrew" });
3105+
// => 1970-02-21[u-ca=hebrew]
31023106
/* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" });
31033107
// => throws (either year or monthCode is required)
31043108
md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]");

0 commit comments

Comments
 (0)