microsoft / microsoft/TypeScript

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

Ouverte
#64,227 1 commentaire 1 réaction 2 personnes assignées Voir sur GitHub

@RyanCavanaugh y travaille déjà.

Depuis le 19/9/2026.

  • #64346 par @copilot-swe-agent — ouverte
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

### ⚙ 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.

```TypeScript
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/toLocaleString#options):

> The timeZone option must not be provided, as it is automatically set to be the date-time's [timeZoneId](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/timeZoneId).

The type definitions should be changed to

```typescript
declare namespace Temporal {
// ...
interface ZonedDateTimeToLocaleStringOptions extends Omit {}
// ...
interface ZonedDateTime {
// ...
toLocaleString(locales?: Intl.LocalesArgument, options?: ZonedDateTimeToLocaleStringOptions): string;
}
}
```

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.