@@ -19,18 +19,28 @@ import { currentRenderingInstance } from './componentRenderContext'
1919import { callWithAsyncErrorHandling , ErrorCodes } from './errorHandling'
2020import { ComponentPublicInstance } from './componentPublicInstance'
2121
22- export interface DirectiveBinding < V = any > {
22+ export interface DirectiveBinding <
23+ V = any ,
24+ Arg extends string = string ,
25+ Modifiers extends string = string
26+ > {
2327 instance : ComponentPublicInstance | null
2428 value : V
2529 oldValue : V | null
26- arg ?: string
27- modifiers : DirectiveModifiers
30+ arg ?: Arg
31+ modifiers : DirectiveModifiers < Modifiers >
2832 dir : ObjectDirective < any , V >
2933}
3034
31- export type DirectiveHook < T = any , Prev = VNode < any , T > | null , V = any > = (
35+ export type DirectiveHook <
36+ T = any ,
37+ Prev = VNode < any , T > | null ,
38+ V = any ,
39+ Arg extends string = string ,
40+ Modifiers extends string = string
41+ > = (
3242 el : T ,
33- binding : DirectiveBinding < V > ,
43+ binding : DirectiveBinding < V , Arg , Modifiers > ,
3444 vnode : VNode < any , T > ,
3545 prevVNode : Prev
3646) => void
@@ -40,14 +50,19 @@ export type SSRDirectiveHook = (
4050 vnode : VNode
4151) => Data | undefined
4252
43- export interface ObjectDirective < T = any , V = any > {
44- created ?: DirectiveHook < T , null , V >
45- beforeMount ?: DirectiveHook < T , null , V >
46- mounted ?: DirectiveHook < T , null , V >
47- beforeUpdate ?: DirectiveHook < T , VNode < any , T > , V >
48- updated ?: DirectiveHook < T , VNode < any , T > , V >
49- beforeUnmount ?: DirectiveHook < T , null , V >
50- unmounted ?: DirectiveHook < T , null , V >
53+ export interface ObjectDirective <
54+ T = any ,
55+ V = any ,
56+ Arg extends string = string ,
57+ Modifiers extends string = string
58+ > {
59+ created ?: DirectiveHook < T , null , V , Arg , Modifiers >
60+ beforeMount ?: DirectiveHook < T , null , V , Arg , Modifiers >
61+ mounted ?: DirectiveHook < T , null , V , Arg , Modifiers >
62+ beforeUpdate ?: DirectiveHook < T , VNode < any , T > , V , Arg , Modifiers >
63+ updated ?: DirectiveHook < T , VNode < any , T > , V , Arg , Modifiers >
64+ beforeUnmount ?: DirectiveHook < T , null , V , Arg , Modifiers >
65+ unmounted ?: DirectiveHook < T , null , V , Arg , Modifiers >
5166 getSSRProps ?: SSRDirectiveHook
5267}
5368
@@ -57,7 +72,7 @@ export type Directive<T = any, V = any> =
5772 | ObjectDirective < T , V >
5873 | FunctionDirective < T , V >
5974
60- export type DirectiveModifiers = Record < string , boolean >
75+ export type DirectiveModifiers < K extends string = string > = Record < K , boolean >
6176
6277const isBuiltInDirective = /*#__PURE__*/ makeMap (
6378 'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text'
0 commit comments