microsoft / microsoft/TypeScript

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

Aperta
#64,227 1 commento 1 reazione 2 assegnatari Vedi su GitHub

@RyanCavanaugh ci sta già lavorando.

Dal 19/9/2026.

  • #64346 di @copilot-swe-agent — aperta
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

### ⚙ 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;
}
}
```

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.