diff --git a/packages/runtime-core/src/directives.ts b/packages/runtime-core/src/directives.ts index f5e0eb1ba0b..08d29a88b62 100644 --- a/packages/runtime-core/src/directives.ts +++ b/packages/runtime-core/src/directives.ts @@ -19,18 +19,18 @@ import { currentRenderingInstance } from './componentRenderUtils' import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling' import { ComponentPublicInstance } from './componentProxy' -export interface DirectiveBinding { +export interface DirectiveBinding { instance: ComponentPublicInstance | null - value: any - oldValue: any + value: V + oldValue: V | null arg?: string modifiers: DirectiveModifiers - dir: ObjectDirective + dir: ObjectDirective } -export type DirectiveHook | null> = ( +export type DirectiveHook | null, V = any> = ( el: T, - binding: DirectiveBinding, + binding: DirectiveBinding, vnode: VNode, prevVNode: Prev ) => void @@ -40,19 +40,21 @@ export type SSRDirectiveHook = ( vnode: VNode ) => Data | undefined -export interface ObjectDirective { - beforeMount?: DirectiveHook - mounted?: DirectiveHook - beforeUpdate?: DirectiveHook> - updated?: DirectiveHook> - beforeUnmount?: DirectiveHook - unmounted?: DirectiveHook +export interface ObjectDirective { + beforeMount?: DirectiveHook + mounted?: DirectiveHook + beforeUpdate?: DirectiveHook, V> + updated?: DirectiveHook, V> + beforeUnmount?: DirectiveHook + unmounted?: DirectiveHook getSSRProps?: SSRDirectiveHook } -export type FunctionDirective = DirectiveHook +export type FunctionDirective = DirectiveHook -export type Directive = ObjectDirective | FunctionDirective +export type Directive = + | ObjectDirective + | FunctionDirective export type DirectiveModifiers = Record