-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add directives type support (#863)
- Loading branch information
1 parent
b3e61a4
commit 678a4b3
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { VNodeDirective, VNode } from 'vue' | ||
|
||
export type DirectiveModifiers = Record<string, boolean> | ||
|
||
export interface DirectiveBinding<V> extends Readonly<VNodeDirective> { | ||
readonly modifiers: DirectiveModifiers | ||
readonly value: V | ||
readonly oldValue: V | null | ||
} | ||
|
||
export type DirectiveHook<T = any, Prev = VNode | null, V = any> = ( | ||
el: T, | ||
binding: DirectiveBinding<V>, | ||
vnode: VNode, | ||
prevVNode: Prev | ||
) => void | ||
|
||
export interface ObjectDirective<T = any, V = any> { | ||
bind?: DirectiveHook<T, any, V> | ||
inserted?: DirectiveHook<T, any, V> | ||
update?: DirectiveHook<T, any, V> | ||
componentUpdated?: DirectiveHook<T, any, V> | ||
unbind?: DirectiveHook<T, any, V> | ||
} | ||
export type FunctionDirective<T = any, V = any> = DirectiveHook<T, any, V> | ||
|
||
export type Directive<T = any, V = any> = | ||
| ObjectDirective<T, V> | ||
| FunctionDirective<T, V> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters