-
Notifications
You must be signed in to change notification settings - Fork 31
Update TS types of TimeZone-like/Calendar-like params to match spec and polyfill #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update TS types of TimeZone-like/Calendar-like params to match spec and polyfill #126
Conversation
Extends TS tsupport for property-bag form of Calendar-like and TimeZone-like params in Temporal methods. Fixes js-temporal#118 Also allows `Temporal.Calendar` instances to be used in the `Intl.DateTimeFormatOptions` type. (Previously only string IDs were allowed. Fixes js-temporal#124. Note that fixing tc39/proposal-temporal#2005 will further extend the types that can be passed into the `calendar` and `timeZone` properties of `Intl.DateTimeFormatOptions`. But that requires a spec change and polyfill code change, so in this commit we'll only extend `Intl.DateTimeFormatOptions` to what's supported by the current spec and polyfill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a couple of questions though:
- Update type declarations for "Timezone-like" and "Calendar-like" parameters to support ZDT property bags #118 mentions removing a cast: https://github.com/js-temporal/temporal-polyfill/pull/109/files#r779978091, should that be part of this PR?
- does this encode the "no recursive property bags" rule or is that coming in a follow-up?
With the type updates in this PR, a few type casts are not needed. See https://github.com/js-temporal/temporal-polyfill/pull/109/files#r780638159 for more context.
Good catch! Thanks for remembering that. Fixed now in latest commit. (Both the timezone and the calendar cast could be removed.)
I couldn't figure out how to encode that in TS types. Tried a few ways to do it, none of them seemed to work. So leaving that for someone with better TypeScript Fu than me. |
Well, certainly not me. I salute whoever it is! |
Actually, I take that back. If an object bag is used, then its |
Extends TS tsupport for property-bag form of Calendar-like and TimeZone-like params in Temporal methods. Fixes #118
Also allows
Temporal.Calendar
instances to be used in theIntl.DateTimeFormatOptions
type. (Previously only string IDs were allowed.) Fixes #124.Note that fixing tc39/proposal-temporal#2005 will further extend the types that can be passed into the
calendar
andtimeZone
properties ofIntl.DateTimeFormatOptions
. But that requires a spec change and polyfill code change, so in this PR we'll only extendIntl.DateTimeFormatOptions
to what's supported by the current spec and polyfill.