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

feat(types): Add type definition for default constructor in IJestHasteMap #14612

Closed
wants to merge 5 commits into from

Conversation

Mutesa-Cedric
Copy link
Contributor

Summary

This commit adds a type definition for the default constructor in the IJestHasteMap interface. Now, the type system will recognize the default constructor as a new instance of IHasteMap, allowing for more accurate type checking and improved code assistance.

Before, when initializing a new HasteMap, the result was of type any.
After adding type definitions for default constructor, now the result have a type of IHasteMap.
This will result in improved developer experience while using jest-haste-map package.

Test plan

Before adding those type definitions, it looked like this :

image

and the resulting map had type of any

after adding type definitions , now it looks like this :

image

And the resulting map now has the type of IHasteMap

…eMap

This commit adds a type definition for the default constructor in the IJestHasteMap interface.
Now, the type system will recognize the default constructor as a new instance of IHasteMap, allowing for more accurate type checking and improved code assistance.

Changes Made:
- Added 'default' property to the IJestHasteMap interface with type (new (options: Options) => IHasteMap).
@netlify
Copy link

netlify bot commented Oct 11, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b5768ba
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/652d4eeb5d3482000872c576
😎 Deploy Preview https://deploy-preview-14612--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 11, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

};

// @ts-expect-error(property `default is missing in HasteMap class`)
Copy link
Member

Choose a reason for hiding this comment

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

Can we cast instead or something? Adding type safety followed by a @ts-ignore seems unfortunate 😅

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.

Can you add type tests? And a changelog entry

@Mutesa-Cedric Mutesa-Cedric requested a review from SimenB October 16, 2023 14:56
@Mutesa-Cedric
Copy link
Contributor Author

ping @SimenB

Copy link

github-actions bot commented Jan 2, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants