fix: withInstallDirective type error (#9946)

Co-authored-by: zz <2418184580@qq.com>
This commit is contained in:
BTB
2022-09-28 16:46:14 +08:00
committed by GitHub
parent cc8b816bd9
commit 19bd02b6bb

View File

@@ -1,6 +1,6 @@
import { NOOP } from '@vue/shared'
import type { App } from 'vue'
import type { App, Directive } from 'vue'
import type { SFCInstallWithContext, SFCWithInstall } from './typescript'
export const withInstall = <T, E extends Record<string, any>>(
@@ -30,7 +30,10 @@ export const withInstallFunction = <T>(fn: T, name: string) => {
return fn as SFCInstallWithContext<T>
}
export const withInstallDirective = <T>(directive: T, name: string) => {
export const withInstallDirective = <T extends Directive>(
directive: T,
name: string
) => {
;(directive as SFCWithInstall<T>).install = (app: App): void => {
app.directive(name, directive)
}