microsoft / microsoft/TypeScript
The `options` arg of `Temporal.ZonedDateTime.prototype.toLocaleString()` currently accepts "illegal" option `timeZone`
オープン
Bug
Domain: lib.d.ts
Help Wanted
Needs Human Review
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
⚙ 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;
}
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。