Skip to content

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

Merged
JoseLion merged 1 commit intomainfrom
fix/plugins-usage
Jan 26, 2024
Merged

fix(core): Allow arrays of plugins on usePlugin(..)#116
JoseLion merged 1 commit intomainfrom
fix/plugins-usage

Conversation

@JoseLion
Copy link
Contributor

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
Contributor 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
@JoseLion JoseLion deleted the fix/plugins-usage branch January 26, 2024 19:18
@github-actions
Copy link

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
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