diff --git a/packages/runtime-core/src/directives.ts b/packages/runtime-core/src/directives.ts index 434ab83f..f5e0eb1b 100644 --- a/packages/runtime-core/src/directives.ts +++ b/packages/runtime-core/src/directives.ts @@ -28,11 +28,11 @@ export interface DirectiveBinding { dir: ObjectDirective } -export type DirectiveHook = ( +export type DirectiveHook | null> = ( el: T, binding: DirectiveBinding, vnode: VNode, - prevVNode: VNode | null + prevVNode: Prev ) => void export type SSRDirectiveHook = ( @@ -41,12 +41,12 @@ export type SSRDirectiveHook = ( ) => Data | undefined export interface ObjectDirective { - beforeMount?: DirectiveHook - mounted?: DirectiveHook - beforeUpdate?: DirectiveHook - updated?: DirectiveHook - beforeUnmount?: DirectiveHook - unmounted?: DirectiveHook + beforeMount?: DirectiveHook + mounted?: DirectiveHook + beforeUpdate?: DirectiveHook> + updated?: DirectiveHook> + beforeUnmount?: DirectiveHook + unmounted?: DirectiveHook getSSRProps?: SSRDirectiveHook } diff --git a/packages/runtime-dom/src/directives/vModel.ts b/packages/runtime-dom/src/directives/vModel.ts index 46336489..703ee722 100644 --- a/packages/runtime-dom/src/directives/vModel.ts +++ b/packages/runtime-dom/src/directives/vModel.ts @@ -1,6 +1,7 @@ import { ObjectDirective, VNode, + DirectiveHook, DirectiveBinding, warn } from '@vue/runtime-core' @@ -240,7 +241,7 @@ function callModelHook( modelToUse = vModelText } } - const fn = modelToUse[hook] + const fn = modelToUse[hook] as DirectiveHook fn && fn(el, binding, vnode, prevVNode) }