@@ -19,18 +19,28 @@ import { currentRenderingInstance } from './componentRenderContext'
19
19
import { callWithAsyncErrorHandling , ErrorCodes } from './errorHandling'
20
20
import { ComponentPublicInstance } from './componentPublicInstance'
21
21
22
- export interface DirectiveBinding < V = any > {
22
+ export interface DirectiveBinding <
23
+ V = any ,
24
+ Arg extends string = string ,
25
+ Modifiers extends string = string
26
+ > {
23
27
instance : ComponentPublicInstance | null
24
28
value : V
25
29
oldValue : V | null
26
- arg ?: string
27
- modifiers : DirectiveModifiers
30
+ arg ?: Arg
31
+ modifiers : DirectiveModifiers < Modifiers >
28
32
dir : ObjectDirective < any , V >
29
33
}
30
34
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
+ > = (
32
42
el : T ,
33
- binding : DirectiveBinding < V > ,
43
+ binding : DirectiveBinding < V , Arg , Modifiers > ,
34
44
vnode : VNode < any , T > ,
35
45
prevVNode : Prev
36
46
) => void
@@ -40,14 +50,19 @@ export type SSRDirectiveHook = (
40
50
vnode : VNode
41
51
) => Data | undefined
42
52
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 >
51
66
getSSRProps ?: SSRDirectiveHook
52
67
}
53
68
@@ -57,7 +72,7 @@ export type Directive<T = any, V = any> =
57
72
| ObjectDirective < T , V >
58
73
| FunctionDirective < T , V >
59
74
60
- export type DirectiveModifiers = Record < string , boolean >
75
+ export type DirectiveModifiers < K extends string = string > = Record < K , boolean >
61
76
62
77
const isBuiltInDirective = /*#__PURE__*/ makeMap (
63
78
'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text'
0 commit comments