Skip to content

Commit c7a10fd

Browse files
fix: correctly capture DOM/Vue wrapper type
1 parent 48065a6 commit c7a10fd

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/config.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import { ComponentPublicInstance } from 'vue'
22
import { GlobalMountOptions } from './types'
33
import { VueWrapper } from './vueWrapper'
4+
import { DOMWrapper } from './domWrapper'
45

56
interface GlobalConfigOptions {
67
global: GlobalMountOptions
78
plugins: {
8-
VueWrapper: Pluggable
9-
DOMWrapper: Pluggable
9+
VueWrapper: Pluggable<VueWrapper<ComponentPublicInstance>>
10+
DOMWrapper: Pluggable<DOMWrapper<Element>>
1011
}
1112
renderStubDefaultSlot: boolean
1213
}
1314

14-
interface Plugin {
15-
handler: (
16-
instance: VueWrapper<ComponentPublicInstance>
17-
) => Record<string, any>
15+
interface Plugin<Instance> {
16+
handler: (instance: Instance) => Record<string, any>
1817
options: Record<string, any>
1918
}
2019

21-
class Pluggable {
22-
installedPlugins: Plugin[] = []
20+
class Pluggable<Instance = DOMWrapper<Element>> {
21+
installedPlugins: Plugin<Instance>[] = []
2322

2423
install(
25-
handler: (
26-
instance: VueWrapper<ComponentPublicInstance>
27-
) => Record<string, any>,
24+
handler: (instance: Instance) => Record<string, any>,
2825
options: Record<string, any> = {}
2926
) {
3027
if (typeof handler !== 'function') {
@@ -34,8 +31,8 @@ class Pluggable {
3431
this.installedPlugins.push({ handler, options })
3532
}
3633

37-
extend(instance: VueWrapper<ComponentPublicInstance>) {
38-
const invokeSetup = (plugin: Plugin) => plugin.handler(instance) // invoke the setup method passed to install
34+
extend(instance: Instance) {
35+
const invokeSetup = (plugin: Plugin<Instance>) => plugin.handler(instance) // invoke the setup method passed to install
3936
const bindProperty = ([property, value]: [string, any]) => {
4037
;(instance as any)[property] =
4138
typeof value === 'function' ? value.bind(instance) : value

0 commit comments

Comments
 (0)