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

fix(core): Allow arrays of plugins on usePlugin(..) #116

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

JoseLion
Copy link
Member

Some plugins might consist of multiple assertion instances. These plugins might want to expose a single variable to be used by the usePlugin(..) function, so we need the argument so accept a single plugin (for backward compact) or an array of them.

@JoseLion JoseLion self-assigned this Jan 24, 2024
Comment on lines +28 to +29
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function usePlugin<P extends Plugin<any, Assertion<any>>>(plugins: P | P[]): void {
Copy link
Member Author

Choose a reason for hiding this comment

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

I wish there were a better way to get rid of these any, but without them, the argument cannot accept an array of union types. For example, [Plugin<X, XAssertion>, Plugin<Y, YAssertion>] will not work.

Copy link
Contributor

@ChristianSama ChristianSama left a comment

Choose a reason for hiding this comment

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

LGTM!

@JoseLion JoseLion merged commit 7dcef4c into main Jan 26, 2024
4 checks passed
@JoseLion JoseLion deleted the fix/plugins-usage branch January 26, 2024 19:18
Copy link

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 1.0.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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants