Repository navigation
Disallow 'timeZone' option in Temporal.ZonedDateTime.prototype.toLocaleString - #65391
Open
bodapatisaikrishna wants to merge 1 commit into
Conversation
…leString Per ECMA-402 Temporal, ZonedDateTime.prototype.toLocaleString rejects the timeZone option because the receiver's timeZoneId is always used. Introduce ZonedDateTimeToLocaleStringOptions extending Omit<Intl.DateTimeFormatOptions, "timeZone"> and update the compiler baselines. Fixes microsoft#64227
Copilot stopped reviewing on behalf of
bodapatisaikrishna due to an error
November 8, 2026 08:52
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
1 open issue
What changed in this PR
Updates Temporal ZonedDateTime#toLocaleString typing to disallow the timeZone option (aligning with the intended API constraints) and adds regression coverage for #64227.
Changes:
- Introduced
Temporal.ZonedDateTimeToLocaleStringOptionsasOmit<Intl.DateTimeFormatOptions, "timeZone">. - Updated
ZonedDateTime#toLocaleStringsignature to use the new options type. - Added compiler test cases + updated baselines to validate the new typing and expected errors.
| File | Description |
|---|---|
| tsc/testdata/tests/cases/compiler/temporal.ts | Adds regression calls for ZonedDateTime#toLocaleString (including timeZone) to lock in behavior. |
| tsc/internal/bundled/libs/lib.esnext.temporal.d.ts | Introduces a dedicated options type and updates toLocaleString to exclude timeZone. |
| tsc/testdata/baselines/reference/compiler/temporal.types | Baseline updates reflecting the new toLocaleString options type. |
| tsc/testdata/baselines/reference/compiler/temporal.symbols | Baseline updates for symbol binding of the new test block. |
| tsc/testdata/baselines/reference/compiler/temporal.js | Baseline updates for JS emit including the new test block. |
| tsc/testdata/baselines/reference/compiler/temporal.errors.txt | Baseline updates capturing new expected TS2353 errors for timeZone in options. |
Review effort: Lite
Comment on lines
+1829
to
+1830
| zdt.toLocaleString(undefined, { timeZone: "Europe/Berlin" }); | ||
| zdt.toLocaleString("en-US", { timeZone: "Europe/Berlin" }); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Under ECMA-402 Temporal,
Temporal.ZonedDateTime.prototype.toLocaleStringstrictly disallows passing atimeZoneoption because the receiver's time zone is always used (engines throw aTypeErrorif provided).This PR introduces
Temporal.ZonedDateTimeToLocaleStringOptionsextendingOmit<Intl.DateTimeFormatOptions, "timeZone">, updatesZonedDateTime.prototype.toLocaleString()to use it, and updates compiler baselines.Fixes #64227
(Note: Authored with AI assistance and verified locally against the compiler baseline suite.)