Repository navigation
Disallow timeZone option in Temporal.ZonedDateTime.prototype.toLocaleString - #65434
Open
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Open
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Conversation
…caleString Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
…String Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix illegal option timeZone in Temporal.ZonedDateTime
Disallow Nov 10, 2026
timeZone option in Temporal.ZonedDateTime.prototype.toLocaleString
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Nov 10, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Temporal locale-options declaration change.
No open issues 🎉
What changed in this PR
Updates TypeScript’s Temporal declarations to reject timeZone in object-literal options passed to ZonedDateTime.toLocaleString, addressing #64227 while preserving compatibility with Intl.DateTimeFormatOptions variables.
Changes:
- Adds a dedicated options interface that omits
timeZone. - Adds regression coverage for rejected literals, valid options, and unchanged behavior of other Temporal types.
- Updates diagnostic, type, and symbol baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/temporalZonedDateTimeToLocaleStringTimeZone.ts |
Adds focused regression coverage. |
tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.types |
Records types for the new test. |
tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.symbols |
Records symbol bindings for the new test. |
tsc/testdata/baselines/reference/compiler/temporalZonedDateTimeToLocaleStringTimeZone.errors.txt |
Records two rejected timeZone literals. |
tsc/testdata/baselines/reference/compiler/temporal.types |
Updates existing method signature baselines. |
tsc/testdata/baselines/reference/compiler/temporal.errors.txt |
Adds the diagnostic for existing invalid usage. |
tsc/internal/bundled/libs/lib.esnext.temporal.d.ts |
Defines and applies the dedicated options interface. |
Review effort: Balanced
Ryan Cavanaugh (RyanCavanaugh)
enabled auto-merge
November 10, 2026 23:39
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.
ZonedDateTime#toLocaleStringalways formats in the receiver's own time zone. JavaScriptCore, SpiderMonkey and V8 all throwTypeErrorif atimeZoneoption is passed. The lib typedoptionsas plainIntl.DateTimeFormatOptions, so the bad call type-checked:Changes
lib.esnext.temporal.d.tsTemporal.ZonedDateTimeToLocaleStringOptions extends Omit<Intl.DateTimeFormatOptions, "timeZone"> {}, the shape the issue proposed. It follows theYearMonthLikeObject extends Omit<…>pattern already in this file.ZonedDateTime.toLocaleStringnow takes this type. The other Temporal types still accepttimeZone, matching the spec.temporalZonedDateTimeToLocaleStringTimeZone.tscovers:timeZone, which now error;ZonedDateTimeoptions;Intl.DateTimeFormatOptionsvariable, which is still accepted;Instant/PlainDateTimestill acceptingtimeZone.temporal.ts, the line already marked/* WRONG */now reports the error.temporal.typesreflects the new parameter type.Design notes
Omitand nottimeZone?: never:Omitonly rejectstimeZonein object literals, through the excess-property check. Values already typed asIntl.DateTimeFormatOptionsare still accepted.timeZone?: never(suggested on Reject timeZone in ZonedDateTime.toLocaleString options #64346) would also catch non-literal values, but it would reject everyIntl.DateTimeFormatOptions-typed variable. That would break the commonconst opts: Intl.DateTimeFormatOptions = …; zdt.toLocaleString(l, opts)pattern.Omit<DateTimeFormatOptions, "timeZone">rather than the interface name. TS 6.0.3 prints the same name for an interface that extendsOmit<…>.optionsarg ofTemporal.ZonedDateTime.prototype.toLocaleString()currently accepts "illegal" optiontimeZone#64227