@@ -3,20 +3,56 @@ import { Base } from "./index.js";
3
3
4
4
const fooPlugin = ( ) => {
5
5
return {
6
- foo : ( ) => "foo" ,
6
+ foo : "foo" ,
7
7
} ;
8
8
} ;
9
+ const barPlugin = ( ) => {
10
+ return {
11
+ bar : "bar" ,
12
+ } ;
13
+ } ;
14
+
15
+ const voidPlugin = ( ) => {
16
+ // returns void
17
+ } ;
18
+
19
+ const base = new Base ( ) ;
20
+
21
+ // @ts -expect-error unknown properties cannot be used, see #31
22
+ base . unknown ;
9
23
10
- const MyBase = Base . plugin ( fooPlugin ) . defaults ( {
24
+ const FooBase = Base . plugin ( fooPlugin ) . defaults ( {
11
25
default : "value" ,
12
26
} ) ;
13
- const base = new MyBase ( {
27
+ const fooBase = new FooBase ( {
14
28
option : "value" ,
15
29
} ) ;
16
30
17
- expectType < string > ( base . options . default ) ;
18
- expectType < string > ( base . options . option ) ;
19
- expectType < string > ( base . foo ( ) ) ;
31
+ expectType < string > ( fooBase . options . default ) ;
32
+ expectType < string > ( fooBase . options . option ) ;
33
+ expectType < string > ( fooBase . foo ) ;
34
+
35
+ const BaseWithVoidPlugin = Base . plugin ( voidPlugin ) ;
36
+ const baseWithVoidPlugin = new BaseWithVoidPlugin ( ) ;
20
37
21
38
// @ts -expect-error unknown properties cannot be used, see #31
22
- base . unknown ;
39
+ baseWithVoidPlugin . unknown ;
40
+
41
+ const BaseWithFooAndBarPlugins = Base . plugin ( barPlugin , fooPlugin ) ;
42
+ const baseWithFooAndBarPlugins = new BaseWithFooAndBarPlugins ( ) ;
43
+
44
+ expectType < string > ( baseWithFooAndBarPlugins . foo ) ;
45
+ expectType < string > ( baseWithFooAndBarPlugins . bar ) ;
46
+
47
+ // @ts -expect-error unknown properties cannot be used, see #31
48
+ baseWithFooAndBarPlugins . unknown ;
49
+
50
+ const BaseWithVoidAndNonVoidPlugins = Base . plugin (
51
+ barPlugin ,
52
+ voidPlugin ,
53
+ fooPlugin
54
+ ) ;
55
+ const baseWithVoidAndNonVoidPlugins = new BaseWithVoidAndNonVoidPlugins ( ) ;
56
+
57
+ expectType < string > ( baseWithVoidAndNonVoidPlugins . foo ) ;
58
+ expectType < string > ( baseWithVoidAndNonVoidPlugins . bar ) ;
0 commit comments