From: 三咲智子 Kevin Deng Date: Thu, 7 Dec 2023 02:46:34 +0000 (+0800) Subject: types(runtime-vapor): add modifiers & argument type X-Git-Tag: v3.6.0-alpha.1~16^2~731 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71bc13575f0805bf33744db7f5edb053e1642d3f;p=thirdparty%2Fvuejs%2Fcore.git types(runtime-vapor): add modifiers & argument type --- diff --git a/packages/runtime-vapor/src/directives.ts b/packages/runtime-vapor/src/directives.ts index 7060a92f4f..70833e9732 100644 --- a/packages/runtime-vapor/src/directives.ts +++ b/packages/runtime-vapor/src/directives.ts @@ -1,41 +1,62 @@ import { isFunction } from '@vue/shared' import { currentInstance, type ComponentInternalInstance } from './component' -import type { DirectiveModifiers } from '@vue/runtime-dom' -export interface DirectiveBinding { +export type DirectiveModifiers = Record + +export interface DirectiveBinding< + V = any, + A = string, + M extends string = string, +> { instance: ComponentInternalInstance | null value: V oldValue: V | null - arg?: string - modifiers?: DirectiveModifiers + arg?: A + modifiers?: DirectiveModifiers dir: ObjectDirective } -export type DirectiveHook = ( - node: T, - binding: DirectiveBinding, -) => void +export type DirectiveHook< + T = any | null, + V = any, + A = string, + M extends string = string, +> = (node: T, binding: DirectiveBinding) => void // create node -> `created` -> node operation -> `beforeMount` -> node mounted -> `mounted` // effect update -> `beforeUpdate` -> node updated -> `updated` // `beforeUnmount`-> node unmount -> `unmounted` -export interface ObjectDirective { - created?: DirectiveHook - beforeMount?: DirectiveHook - mounted?: DirectiveHook - // beforeUpdate?: DirectiveHook - // updated?: DirectiveHook - beforeUnmount?: DirectiveHook - unmounted?: DirectiveHook +export interface ObjectDirective< + T = any, + V = any, + A = string, + M extends string = string, +> { + created?: DirectiveHook + beforeMount?: DirectiveHook + mounted?: DirectiveHook + // beforeUpdate?: DirectiveHook + // updated?: DirectiveHook + beforeUnmount?: DirectiveHook + unmounted?: DirectiveHook // getSSRProps?: SSRDirectiveHook // deep?: boolean } export type DirectiveHookName = Exclude -export type FunctionDirective = DirectiveHook -export type Directive = - | ObjectDirective - | FunctionDirective +export type FunctionDirective< + T = any, + V = any, + A = string, + M extends string = string, +> = DirectiveHook + +export type Directive< + T = any, + V = any, + A = string, + M extends string = string, +> = ObjectDirective | FunctionDirective export type DirectiveArguments = Array< | [Directive | undefined]