@@ -12,23 +12,23 @@ interface GlobalConfigOptions {
12
12
renderStubDefaultSlot : boolean
13
13
}
14
14
15
- interface Plugin < Instance > {
16
- handler : (
17
- instance : Instance ,
18
- options : Record < string , any >
19
- ) => Record < string , any >
20
- options : Record < string , any >
15
+ interface Plugin < Instance , O > {
16
+ handler ( instance : Instance ) : Record < string , any >
17
+ handler ( instance : Instance , options : O ) : Record < string , any >
18
+ options : O
21
19
}
22
20
23
21
class Pluggable < Instance = DOMWrapper < Element > > {
24
- installedPlugins : Plugin < Instance > [ ] = [ ]
22
+ installedPlugins : Plugin < Instance , any > [ ] = [ ]
25
23
26
- install (
27
- handler : (
28
- instance : Instance ,
29
- options ?: Record < string , any >
30
- ) => Record < string , any > ,
31
- options : Record < string , any > = { }
24
+ install < O > ( handler : ( instance : Instance ) => Record < string , any > )
25
+ install < O > (
26
+ handler : ( instance : Instance , options : O ) => Record < string , any > ,
27
+ options : O
28
+ )
29
+ install < O > (
30
+ handler : ( instance : Instance , options ?: O ) => Record < string , any > ,
31
+ options ?: O
32
32
) {
33
33
if ( typeof handler !== 'function' ) {
34
34
console . error ( 'plugin.install must receive a function' )
@@ -38,7 +38,7 @@ class Pluggable<Instance = DOMWrapper<Element>> {
38
38
}
39
39
40
40
extend ( instance : Instance ) {
41
- const invokeSetup = ( { handler, options } : Plugin < Instance > ) => {
41
+ const invokeSetup = ( { handler, options } : Plugin < Instance , any > ) => {
42
42
return handler ( instance , options ) // invoke the setup method passed to install
43
43
}
44
44
const bindProperty = ( [ property , value ] : [ string , any ] ) => {
0 commit comments