-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Add lib.esnext.temporal #62628
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
base: main
Are you sure you want to change the base?
Add lib.esnext.temporal #62628
Conversation
f8fc33a to
9f45da2
Compare
|
We usually don't create tests for Probably we should just delete them? @typescript-bot test it |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
Dealer's choice. I needed them for testing anyway, but if they're of no value within the library then they can just go. |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Well... type DateLikeObjectBase = {
year?: number | undefined;
era?: string | undefined;
eraYear?: number | undefined;
month?: number | undefined;
monthCode?: string | undefined;
day: number;
calendar?: string | undefined;
}
type DateLikeObject = DateLikeObjectBase & ({ month: number } | { monthCode: string });Possibly it's not worth the additional complexity, though. |
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
ef570f6 to
bab5a4a
Compare
|
I know there are existing polyfills for Temporal out there in TS; are these types compatible / based off of those? Or fresh? |
|
The definitions are de novo, so no licensing issues. As for compatibility:
|
| @@ -1,3 +1,12 @@ | |||
| /// <reference lib="esnext.temporal" /> | |||
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.
intl comes before temporal in the libs list. I am not sure if we have cases where earlier libs reference later ones, though maybe that does nothing.
I am not sure if this matters, or in which file it makes sense to declare these...
| total(totalOf: "day" | "days" | TimeUnit): number; | ||
| total(totalOf: DurationTotalOptions): number; | ||
| toString(options?: DurationToStringOptions): string; | ||
| toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; |
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.
I think the options parameter of Duration.toLocaleString is incorrect. The parameters are "the same as in the constructor to Intl.DurationFormat,"12 so the options parameter should not be of type Intl.DateTimeFormatOptions. Among other differences, DurationFormat accepts a key of style34, and DateTimeFormat accepts keys of dateStyle and timeStyle5, but not vice versa.
Footnotes
-
https://tc39.es/proposal-temporal/docs/duration.html#toLocaleString ↩
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration/toLocaleString#options ↩
-
https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor ↩
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style ↩
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#style_shortcuts ↩
Closes #60164.
No custom calendar support, as per the latest spec changes.
There are lots of places in the spec where property bags have "at least one of" constraints (eg. either
monthormonthCodeis mandatory for a DateLikeObject), which can't really be straightforwardly expressed. Otherwise, appears to be playing well.Temporal shipped in Firefox 139, and is staging in Chromium (shipping in 144).