File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,14 @@ export {
20
20
} ;
21
21
22
22
/**
23
- * Extends `@assertive-ts/core` with a local or 3rd-party plugin.
23
+ * Extends `@assertive-ts/core` with local or 3rd-party plugin(s) .
24
24
*
25
- * @param plugin the plugin to use to extend assertive-ts
25
+ * @param plugins a plugin or an array of plugins to use
26
26
* @see {@link Plugin Plugin }
27
27
*/
28
- export function usePlugin < T , A extends Assertion < T > > ( plugin : Plugin < T , A > ) : void {
29
- config . addPlugin ( plugin ) ;
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ export function usePlugin < P extends Plugin < any , Assertion < any > > > ( plugins : P | P [ ] ) : void {
30
+ Array . isArray ( plugins )
31
+ ? plugins . forEach ( plugin => config . addPlugin ( plugin ) )
32
+ : config . addPlugin ( plugins ) ;
30
33
}
Original file line number Diff line number Diff line change 1
1
import { Assertion } from "../Assertion" ;
2
2
3
+ /**
4
+ * A plugin object that can be used to extend the `expect(..)` function.
5
+ *
6
+ * @param T the type the plugin is meant for
7
+ * @param A the type of the assertion for `T`
8
+ */
3
9
export interface Plugin < T , A extends Assertion < T > > {
4
10
/**
5
- * The `Assertion<T>` instance the plugin adds
11
+ * The assertion `A` constructor the plugin adds
6
12
*/
7
13
Assertion : new ( actual : T ) => A ;
8
14
/**
You can’t perform that action at this time.
0 commit comments