Skip to content

Conversation

@tomquist
Copy link
Contributor

Accessing the jest global in ESM must be done either through import.meta.jest or by importing it from @jest/globals. The latter is useful while migrating to ESM because the former is not accessible in non-ESM.

This adds an option to specify the types of globals for which we want to enforce the import.

@tomquist tomquist force-pushed the add-jest-global-types branch 2 times, most recently from 5b7aa20 to 38eb74a Compare April 26, 2024 13:32
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea 👍

@SimenB SimenB requested a review from G-Rath April 26, 2024 13:38
Copy link
Collaborator

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, but I think let's drop the tuple utils stuff - I'm pretty confident we'll not be adding any new types anytime soon, so we should be safe to just directly write out the tuple

@tomquist tomquist requested a review from G-Rath April 26, 2024 21:51
@tomquist tomquist force-pushed the add-jest-global-types branch from beb5655 to 2f342f5 Compare April 26, 2024 21:56
Accessing the `jest` global in ESM must be done either through `import.meta.jest` or by importing it from `@jest/globals`. The latter is useful while migrating to ESM because the former is not accessible in non-ESM. This adds an option to specify the types of globals for which we want to enforce the import.
@tomquist tomquist force-pushed the add-jest-global-types branch from 2f342f5 to cb9d9fd Compare April 26, 2024 21:58
@tomquist
Copy link
Contributor Author

Thanks for the quick review!

@G-Rath G-Rath merged commit c464ae3 into jest-community:main Apr 27, 2024
github-actions bot pushed a commit that referenced this pull request Apr 27, 2024
# [28.3.0](v28.2.0...v28.3.0) (2024-04-27) ### Features * prefer importing jest globals for specific types ([#1568](#1568)) ([c464ae3](c464ae3))
@github-actions
Copy link

🎉 This PR is included in version 28.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants