microsoft / microsoft/TypeScript

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

Offen
#64,227 1 Kommentar 1 Reaktion 2 zugewiesene Personen Auf GitHub ansehen

@RyanCavanaugh arbeitet bereits daran.

Seit 19.9.2026.

  • #64346 von @copilot-swe-agent — offen
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

⚙ Compilation target

ESNext

⚙ Library

ESNext

Missing / Incorrect Definition

https://github.com/microsoft/TypeScript/blob/0b832e12235cc3db14a4be6501827c2f8a8a8569/tsc/internal/bundled/libs/lib.esnext.temporal.d.ts#L320

Sample Code

TypeScript allows the following code, when it should not.

Temporal.Now.zonedDateTimeISO("America/Chicago").toLocaleString(undefined, { timeZone: "Europe/Berlin" });
Result
Engine Error
JavaScriptCore TypeError: ZonedDateTime.toLocaleString does not accept a timeZone option; the ZonedDateTime's time zone is used
SpiderMonkey TypeError: can't set option timeZone when Temporal.ZonedDateTime.toLocaleString is used
V8 TypeError: Invalid time zone specified: America/Chicago
Documentation Link

According to MDN:

The timeZone option must not be provided, as it is automatically set to be the date-time's timeZoneId.

The type definitions should be changed to

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.