Skip to content

Disallow illegal 'timeZone' option in Temporal.ZonedDateTime.prototype.toLocaleString (#64227) - #65422

Closed
Mar Mejia (mechazod) wants to merge 1 commit into
microsoft:mainfrom
mechazod:fix/temporal-zoneddatetime-locale-options
Closed

Mar Mejia (mechazod) wants to merge 1 commit into
microsoft:mainfrom
mechazod:fix/temporal-zoneddatetime-locale-options

Conversation

@mechazod

Copy link
Copy Markdown

Fixes #64227

According to the ECMAScript Temporal specification and MDN documentation, Temporal.ZonedDateTime.prototype.toLocaleString() explicitly forbids providing the timeZone property in the options bag (passing a timeZone option throws a runtime TypeError in JS engines like V8, JavaScriptCore, and SpiderMonkey because the instance's own time zone is strictly used).

This PR introduces ZonedDateTimeToLocaleStringOptions extending Omit<Intl.DateTimeFormatOptions, "timeZone"> and updates Temporal.ZonedDateTime.prototype.toLocaleString to use this type, preventing illegal timeZone options from passing type checking.

Changes

  • Added interface ZonedDateTimeToLocaleStringOptions extends Omit<Intl.DateTimeFormatOptions, "timeZone"> {}
  • Updated Temporal.ZonedDateTime.toLocaleString(locales?: Intl.LocalesArgument, options?: ZonedDateTimeToLocaleStringOptions): string;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 10, 2026
@jakebailey

Copy link
Copy Markdown
Member

I thought we had a PR for this that had discussion?

@jakebailey

Copy link
Copy Markdown
Member

I must be hallucinating because I cannot find it

@RyanCavanaugh

Copy link
Copy Markdown
Member

CI failing, please someone who can run hereby test open a PR.

@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 10, 2026
@mechazod

Copy link
Copy Markdown
Author

Ryan Cavanaugh (@RyanCavanaugh) I will revise the MR to include baseline test to fix the CI.

@Sector6759

Copy link
Copy Markdown

I must be hallucinating because I cannot find it

You're not, but for some reason all traces to the person who first created a PR are now erased from the issue (#64227). Maybe they deleted their GitHub account.

In that first PR, Copilot gave a hint that passing the timeZone option in a structurally assignable non-literal options object is still possible. So I suggested the following change, which was implemented in that first PR.

interface ZonedDateTimeToLocaleStringOptions extends Intl.DateTimeFormatOptions {
    timeZone?: never;
}

The last open PR now explicitly adds a note why Omit<> is preferred over timeZone?: never.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

The options arg of Temporal.ZonedDateTime.prototype.toLocaleString() currently accepts "illegal" option timeZone

5 participants