From 31ff6dde7d7cf9e6b630edc54c8227e1e4f636e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 21:48:49 +0000 Subject: [PATCH 1/3] Initial plan From 60420fda810353863425caa6051a24bdfc8def75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 21:55:36 +0000 Subject: [PATCH 2/3] Add test for timeZone option in Temporal.ZonedDateTime.prototype.toLocaleString Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...onedDateTimeToLocaleStringTimeZone.symbols | 81 +++++++++++++ ...lZonedDateTimeToLocaleStringTimeZone.types | 108 ++++++++++++++++++ ...oralZonedDateTimeToLocaleStringTimeZone.ts | 26 +++++ 3 files changed, 215 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types create mode 100644 tsc/testdata/tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts diff --git a/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.symbols b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.symbols new file mode 100644 index 0000000000000..cbdd3398f6b03 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.symbols @@ -0,0 +1,81 @@ +//// [tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts] //// + +=== temporalZonedDateTimeToLocaleStringTimeZone.ts === +// https://github.com/microsoft/TypeScript/issues/64227 + +declare const zdt: Temporal.ZonedDateTime; +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + +// Error: ZonedDateTime always formats in its own time zone +zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>undefined : Symbol(undefined) +>timeZone : Symbol(timeZone, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 5, 31)) + +zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 6, 29)) +>weekday : Symbol(weekday, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 6, 59)) + +// OK +zdt.toLocaleString(); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + +zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 10, 29)) +>timeZoneName : Symbol(timeZoneName, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 10, 44)) + +zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }); +>zdt.withTimeZone("Europe/Berlin").toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dateStyle : Symbol(dateStyle, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 11, 59)) +>timeStyle : Symbol(timeStyle, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 11, 78)) + +declare const options: Intl.DateTimeFormatOptions; +>options : Symbol(options, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 13, 13)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 7 more) +>DateTimeFormatOptions : Symbol(Intl.DateTimeFormatOptions, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) + +zdt.toLocaleString("en-US", options); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 2, 13)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>options : Symbol(options, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 13, 13)) + +// OK: other Temporal types still accept a timeZone option +declare const instant: Temporal.Instant; +>instant : Symbol(instant, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 17, 13)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + +instant.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); +>instant.toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 17, 13)) +>toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 18, 33)) + +declare const plainDateTime: Temporal.PlainDateTime; +>plainDateTime : Symbol(plainDateTime, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 19, 13)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + +plainDateTime.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); +>plainDateTime.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateTime : Symbol(plainDateTime, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 19, 13)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporalZonedDateTimeToLocaleStringTimeZone.ts, 20, 39)) + diff --git a/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types new file mode 100644 index 0000000000000..76ef7eadd7c8f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types @@ -0,0 +1,108 @@ +//// [tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts] //// + +=== temporalZonedDateTimeToLocaleStringTimeZone.ts === +// https://github.com/microsoft/TypeScript/issues/64227 + +declare const zdt: Temporal.ZonedDateTime; +>zdt : Temporal.ZonedDateTime +>Temporal : any + +// Error: ZonedDateTime always formats in its own time zone +zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); +>zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }) : string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt : Temporal.ZonedDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>undefined : undefined +>{ timeZone: "Europe/Berlin" } : { timeZone: string; } +>timeZone : string +>"Europe/Berlin" : "Europe/Berlin" + +zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); +>zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }) : string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt : Temporal.ZonedDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"de-DE" : "de-DE" +>{ timeZone: "Pacific/Auckland", weekday: "long" } : { timeZone: string; weekday: "long"; } +>timeZone : string +>"Pacific/Auckland" : "Pacific/Auckland" +>weekday : "long" +>"long" : "long" + +// OK +zdt.toLocaleString(); +>zdt.toLocaleString() : string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt : Temporal.ZonedDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string + +zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }); +>zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }) : string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt : Temporal.ZonedDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"en-US" : "en-US" +>{ month: "long", timeZoneName: "short" } : { month: "long"; timeZoneName: "short"; } +>month : "long" +>"long" : "long" +>timeZoneName : "short" +>"short" : "short" + +zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }); +>zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }) : string +>zdt.withTimeZone("Europe/Berlin").toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.withTimeZone("Europe/Berlin") : Temporal.ZonedDateTime +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +>zdt : Temporal.ZonedDateTime +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +>"Europe/Berlin" : "Europe/Berlin" +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"de-DE" : "de-DE" +>{ dateStyle: "full", timeStyle: "long" } : { dateStyle: "full"; timeStyle: "long"; } +>dateStyle : "full" +>"full" : "full" +>timeStyle : "long" +>"long" : "long" + +declare const options: Intl.DateTimeFormatOptions; +>options : Intl.DateTimeFormatOptions +>Intl : any + +zdt.toLocaleString("en-US", options); +>zdt.toLocaleString("en-US", options) : string +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt : Temporal.ZonedDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"en-US" : "en-US" +>options : Intl.DateTimeFormatOptions + +// OK: other Temporal types still accept a timeZone option +declare const instant: Temporal.Instant; +>instant : Temporal.Instant +>Temporal : any + +instant.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); +>instant.toLocaleString("en-US", { timeZone: "Europe/Berlin" }) : string +>instant.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>instant : Temporal.Instant +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"en-US" : "en-US" +>{ timeZone: "Europe/Berlin" } : { timeZone: string; } +>timeZone : string +>"Europe/Berlin" : "Europe/Berlin" + +declare const plainDateTime: Temporal.PlainDateTime; +>plainDateTime : Temporal.PlainDateTime +>Temporal : any + +plainDateTime.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); +>plainDateTime.toLocaleString("en-US", { timeZone: "Europe/Berlin" }) : string +>plainDateTime.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>plainDateTime : Temporal.PlainDateTime +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>"en-US" : "en-US" +>{ timeZone: "Europe/Berlin" } : { timeZone: string; } +>timeZone : string +>"Europe/Berlin" : "Europe/Berlin" + diff --git a/tsc/testdata/tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts b/tsc/testdata/tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts new file mode 100644 index 0000000000000..f4a01c37e647e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts @@ -0,0 +1,26 @@ +// @target: esnext +// @lib: esnext +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/64227 + +declare const zdt: Temporal.ZonedDateTime; + +// Error: ZonedDateTime always formats in its own time zone +zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); +zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); + +// OK +zdt.toLocaleString(); +zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }); +zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }); + +declare const options: Intl.DateTimeFormatOptions; +zdt.toLocaleString("en-US", options); + +// OK: other Temporal types still accept a timeZone option +declare const instant: Temporal.Instant; +instant.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); +declare const plainDateTime: Temporal.PlainDateTime; +plainDateTime.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); From 07edf1b2d2a53d3b7871b05cdb28406509be7a28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 21:57:03 +0000 Subject: [PATCH 3/3] Disallow timeZone option in Temporal.ZonedDateTime.prototype.toLocaleString 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 ++++++++--------- ...dDateTimeToLocaleStringTimeZone.errors.txt | 31 +++++++++++++++++++ ...lZonedDateTimeToLocaleStringTimeZone.types | 24 +++++++------- 5 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.errors.txt diff --git a/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts b/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts index 5f1293f455333..9591045df2481 100644 --- a/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts +++ b/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts @@ -275,6 +275,8 @@ declare namespace Temporal { offset?: "use" | "ignore" | "prefer" | "reject" | undefined; } + interface ZonedDateTimeToLocaleStringOptions extends Omit {} + interface ZonedDateTime { readonly calendarId: string; readonly timeZoneId: string; @@ -316,7 +318,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" } diff --git a/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.errors.txt b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.errors.txt new file mode 100644 index 0000000000000..36e523aa5463f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.errors.txt @@ -0,0 +1,31 @@ +temporalZonedDateTimeToLocaleStringTimeZone.ts(6,33): error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. +temporalZonedDateTimeToLocaleStringTimeZone.ts(7,31): error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. + + +==== temporalZonedDateTimeToLocaleStringTimeZone.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/64227 + + declare const zdt: Temporal.ZonedDateTime; + + // Error: ZonedDateTime always formats in its own time zone + zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); + ~~~~~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. + zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); + ~~~~~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'timeZone' does not exist in type 'Omit'. + + // OK + zdt.toLocaleString(); + zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }); + zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }); + + declare const options: Intl.DateTimeFormatOptions; + zdt.toLocaleString("en-US", options); + + // OK: other Temporal types still accept a timeZone option + declare const instant: Temporal.Instant; + instant.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); + declare const plainDateTime: Temporal.PlainDateTime; + plainDateTime.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types index 76ef7eadd7c8f..f93ec61f5d1f1 100644 --- a/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types +++ b/tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types @@ -10,9 +10,9 @@ declare const zdt: Temporal.ZonedDateTime; // Error: ZonedDateTime always formats in its own time zone zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); >zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }) : 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 >undefined : undefined >{ timeZone: "Europe/Berlin" } : { timeZone: string; } >timeZone : string @@ -20,9 +20,9 @@ zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); >zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "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 >"de-DE" : "de-DE" >{ timeZone: "Pacific/Auckland", weekday: "long" } : { timeZone: string; weekday: "long"; } >timeZone : string @@ -33,15 +33,15 @@ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland", weekday: "long" }); // OK zdt.toLocaleString(); >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("en-US", { month: "long", timeZoneName: "short" }); >zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }) : 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" : "en-US" >{ month: "long", timeZoneName: "short" } : { month: "long"; timeZoneName: "short"; } >month : "long" @@ -51,13 +51,13 @@ zdt.toLocaleString("en-US", { month: "long", timeZoneName: "short" }); zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }); >zdt.withTimeZone("Europe/Berlin").toLocaleString("de-DE", { dateStyle: "full", timeStyle: "long" }) : string ->zdt.withTimeZone("Europe/Berlin").toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>zdt.withTimeZone("Europe/Berlin").toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >zdt.withTimeZone("Europe/Berlin") : Temporal.ZonedDateTime >zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime >zdt : Temporal.ZonedDateTime >withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime >"Europe/Berlin" : "Europe/Berlin" ->toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Temporal.ZonedDateTimeToLocaleStringOptions) => string >"de-DE" : "de-DE" >{ dateStyle: "full", timeStyle: "long" } : { dateStyle: "full"; timeStyle: "long"; } >dateStyle : "full" @@ -71,9 +71,9 @@ declare const options: Intl.DateTimeFormatOptions; zdt.toLocaleString("en-US", options); >zdt.toLocaleString("en-US", 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 >"en-US" : "en-US" >options : Intl.DateTimeFormatOptions