The `options` arg of `Temporal.ZonedDateTime.prototype.toLocaleString()` currently accepts "illegal" option `timeZone`
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
⚙ Compilation target
ESNext
⚙ Library
ESNext
Missing / Incorrect Definition
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;
}
}
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64322 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Possible Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64278 · 1 Kommentar · 1 Reaktion ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/TypeScript#64118 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64094 ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#63959 · 5 Kommentare ·
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
kubernetes-sigs/prow#953 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
caddyserver/caddy#8046 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
-
L1 recommended for recruits
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
optimization optimization:agents-md-curator
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
githubnext/gh-aw-cao#13143 ·