-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
coreutils: add required TS intl libraries #16288
base: main
Are you sure you want to change the base?
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
Thanks for making a pull request to jupyterlab! |
packages/coreutils/src/time.ts
Outdated
// Intl.RelativeTimeFormatStyle contains these, but it requires `ES2020.Intl`. | ||
// We currently compile to an `ES2018` target. | ||
export type HumanStyle = 'long' | 'short' | 'narrow'; | ||
export type HumanStyle = Intl.ResolvedRelativeTimeFormatOptions["style"]; |
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.
This could target Intl.RelativeTimeFormatStyle
as originally proposed. The only downside to this is that there is a proposal to rename the RelativeTimeFormat option types to bring them in line with the Intl namespace convention (which would be Intl.RelativeTimeFormatOptionsStyle
), so this type name may be removed or deprecated in a future TypeScript release.
This approach resolves the type to Intl.RelativeTimeFormatStyle
indirectly, so that any such change would be automatically accounted for.
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.
It looks like it does not compile:
../coreutils/lib/time.d.ts(5,28): error TS2724: 'Intl' has no exported member named 'ResolvedRelativeTimeFormatOptions'. Did you mean 'ResolvedDateTimeFormatOptions'?
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.
What was missing from the PR (mea culpa) was the default library set in tsconfigbase. This seems like an acceptable approach, given that Jupyter explicitly relies on features defined in those libraries.
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.
Thanks for opening this PR!
References
Resolves #16283.
Code changes
Explicitly adds the es2020.intl library, required for RelativeTimeFormat and its ancillary types, to tsconfigbase.
Also pre-emptively adds es2021.intl to the coreutils tsconfig, which will be required to avoid build errors in time.ts if/when the DateTimeFormat option properties
dateStyle
andtimeStyle
are moved there from es2020.intl.User-facing changes
Nil. (It's no longer necessary to explicitly define a
HumanStyle
type, but as it's an exported namespace type, it's left as-is.)Backwards-incompatible changes
Nil.