Closed
Description
The current public types for TimeZone.from
look like this:
Line 1125 in e046ccd
But the spec and the polyfill also accept a ZDT-like property bag too, per tc39/proposal-temporal#925. Specifically, they accept any object with a timeZone
property and will use that property's value as the time zone, with one exception: per tc39/proposal-temporal#925 (comment), recursive bags like {timeZone: {timeZone: 'Asia/Tokyo'}}
are disallowed.
Therefore, the declaration should also allow a { timeZone: TimeZoneProtocol | string }
parameter type.
This issue tracks the work to:
- Figure out how to encode the "no recursive bags" in TS types. One possible way (not sure this will work) could be something like this:
type NoRecursiveTimeZones = { timeZone: { timeZone: never } };
. . .
static from(timeZone: TimeZoneProtocol | string | { timeZone: TimeZoneProtocol } | NoRecursiveTimeZones): Temporal.TimeZone | TimeZoneProtocol;
- Use that declaration throughout index.d.ts wherever TimeZone-like parameters are accepted
- Port the changes to proposal-temporal, and verify that the docs are correct for methods that accept a time zone parameter.
- Remove any now-unnecessary type casts, like the one @ptomato found in in https://github.com/js-temporal/temporal-polyfill/pull/109/files#r779978091.
Metadata
Metadata
Assignees
Labels
No labels