From 622dfc977c8080edc0000cb1def93f51060a1f78 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 04:31:42 +0000 Subject: [PATCH 1/2] Initial plan From 9bbe56f4ced9f8605c56eb52c0a98337e4cf2b0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 04:48:17 +0000 Subject: [PATCH 2/2] Reject timeZone for ZonedDateTime locale strings Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- .../bundled/libs/lib.esnext.temporal.d.ts | 4 ++- .../reference/compiler/temporal.errors.txt | 5 +++- .../reference/compiler/temporal.types | 28 +++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts b/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts index 2d18011132a25..6b056816c5277 100644 --- a/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts +++ b/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts @@ -272,6 +272,8 @@ declare namespace Temporal { timeZoneName?: "auto" | "never" | "critical" | undefined; } + interface ZonedDateTimeToLocaleStringOptions extends Omit {} + interface ZonedDateTimeFromOptions extends OverflowOptions, DisambiguationOptions { offset?: "use" | "ignore" | "prefer" | "reject" | undefined; } @@ -317,7 +319,7 @@ declare namespace Temporal { round(roundTo: RoundingOptions<"day" | TimeUnit>): ZonedDateTime; equals(other: ZonedDateTimeLike): boolean; toString(options?: ZonedDateTimeToStringOptions): string; - toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: Intl.LocalesArgument, options?: ZonedDateTimeToLocaleStringOptions): string; toJSON(): string; valueOf(): never; startOfDay(): ZonedDateTime; diff --git a/tsc/testdata/baselines/reference/compiler/temporal.errors.txt b/tsc/testdata/baselines/reference/compiler/temporal.errors.txt index 59d4e125441bd..016d75cd210f4 100644 --- a/tsc/testdata/baselines/reference/compiler/temporal.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/temporal.errors.txt @@ -1,10 +1,11 @@ temporal.ts(25,13): error TS2339: Property 'year' does not exist on type 'Instant'. +temporal.ts(594,47): error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. 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) ==== +==== temporal.ts (5 errors) ==== /** * Test cases derived from documentation at tc39/proposal-temporal, * under the following license: @@ -601,6 +602,8 @@ temporal.ts(1520,8): error TS2339: Property 'month' does not exist on type 'Plai const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); + ~~~~~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' diff --git a/tsc/testdata/baselines/reference/compiler/temporal.types b/tsc/testdata/baselines/reference/compiler/temporal.types index 311de7546db8f..bd564617f8526 100644 --- a/tsc/testdata/baselines/reference/compiler/temporal.types +++ b/tsc/testdata/baselines/reference/compiler/temporal.types @@ -1598,9 +1598,9 @@ >zdt => zdt.toLocaleString("en", { month: "long" }) : (zdt: Temporal.ZonedDateTime) => string >zdt : Temporal.ZonedDateTime >zdt.toLocaleString("en", { month: "long" }) : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"en" : "en" >{ month: "long" } : { month: "long"; } >month : "long" @@ -2604,15 +2604,15 @@ zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM >zdt.toLocaleString() : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' >zdt.toLocaleString("de-DE") : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"de-DE" : "de-DE" const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; @@ -2630,17 +2630,17 @@ zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' >zdt.toLocaleString("de-DE", options) : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"de-DE" : "de-DE" >options : { readonly weekday: "long"; readonly year: "numeric"; readonly month: "long"; readonly day: "numeric"; } /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); >zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }) : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"de-DE" : "de-DE" >{ timeZone: "Pacific/Auckland" } : { timeZone: string; } >timeZone : string @@ -2649,20 +2649,20 @@ // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' >zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE") : string ->zdt.withTimeZone("Pacific/Auckland").toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.withTimeZone("Pacific/Auckland").toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt.withTimeZone("Pacific/Auckland") : Temporal.ZonedDateTime >zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime >zdt : Temporal.ZonedDateTime >withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime >"Pacific/Auckland" : "Pacific/Auckland" ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"de-DE" : "de-DE" zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' >zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12") : string ->zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt : Temporal.ZonedDateTime ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"en-US-u-nu-fullwide-hc-h12" : "en-US-u-nu-fullwide-hc-h12" }