microsoft / microsoft/TypeScript

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

Abierto
#64,227 1 comentario 1 reacción 2 asignados Ver en GitHub

@RyanCavanaugh ya está trabajando en esto.

Desde el 19/9/2026.

  • #64346 de @copilot-swe-agent — abierto
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.