Repository navigation
Disallow illegal 'timeZone' option in Temporal.ZonedDateTime.prototype.toLocaleString (#64227) - #65422
Disallow illegal 'timeZone' option in Temporal.ZonedDateTime.prototype.toLocaleString (#64227)#65422Mar Mejia (mechazod) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
|
I thought we had a PR for this that had discussion? |
|
I must be hallucinating because I cannot find it |
|
CI failing, please someone who can run |
|
Ryan Cavanaugh (@RyanCavanaugh) I will revise the MR to include baseline test to fix the CI. |
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 interface ZonedDateTimeToLocaleStringOptions extends Intl.DateTimeFormatOptions {
timeZone?: never;
}The last open PR now explicitly adds a note why |
Fixes #64227
According to the ECMAScript Temporal specification and MDN documentation,
Temporal.ZonedDateTime.prototype.toLocaleString()explicitly forbids providing thetimeZoneproperty in the options bag (passing atimeZoneoption throws a runtimeTypeErrorin JS engines like V8, JavaScriptCore, and SpiderMonkey because the instance's own time zone is strictly used).This PR introduces
ZonedDateTimeToLocaleStringOptionsextendingOmit<Intl.DateTimeFormatOptions, "timeZone">and updatesTemporal.ZonedDateTime.prototype.toLocaleStringto use this type, preventing illegaltimeZoneoptions from passing type checking.Changes
interface ZonedDateTimeToLocaleStringOptions extends Omit<Intl.DateTimeFormatOptions, "timeZone"> {}Temporal.ZonedDateTime.toLocaleString(locales?: Intl.LocalesArgument, options?: ZonedDateTimeToLocaleStringOptions): string;