Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Renegade334
Copy link

@Renegade334 Renegade334 commented May 6, 2024

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 and timeStyle 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.

Copy link

welcome bot commented May 6, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@Renegade334 Renegade334 changed the title Issue 16283 coreutils: add required TS intl libraries May 6, 2024
// 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"];
Copy link
Author

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.

Copy link
Member

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'?

Copy link
Author

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.

packages/coreutils/src/time.ts Outdated Show resolved Hide resolved
@krassowski krassowski added the bug label May 6, 2024
Copy link
Contributor

@JasonWeill JasonWeill left a 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!

@Renegade334 Renegade334 marked this pull request as ready for review May 9, 2024 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coreutils and post-ES2018 Intl API features
3 participants