Skip to content

Commit 1347fc8

Browse files
KaelWDhefeng
authored and
hefeng
committed
fix(types): make VNodeDirective properties optional, fix vuejs#8013 (vuejs#8003)
1 parent 9100949 commit 1347fc8

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

types/options.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,13 @@ export interface WatchOptionsWithHandler<T> extends WatchOptions {
160160
handler: WatchHandler<T>;
161161
}
162162

163+
export interface DirectiveBinding extends Readonly<VNodeDirective> {
164+
readonly modifiers: { [key: string]: boolean };
165+
}
166+
163167
export type DirectiveFunction = (
164168
el: HTMLElement,
165-
binding: VNodeDirective,
169+
binding: DirectiveBinding,
166170
vnode: VNode,
167171
oldVnode: VNode
168172
) => void;

types/test/options-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ Vue.component('component', {
154154
props: {
155155
myProp: "bar"
156156
},
157+
directives: [{
158+
name: 'a',
159+
value: 'foo'
160+
}],
157161
domProps: {
158162
innerHTML: "baz"
159163
},

types/vnode.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ export interface VNodeData {
5858
}
5959

6060
export interface VNodeDirective {
61-
readonly name: string;
62-
readonly value: any;
63-
readonly oldValue: any;
64-
readonly expression: any;
65-
readonly arg: string;
66-
readonly modifiers: { [key: string]: boolean };
61+
name: string;
62+
value?: any;
63+
oldValue?: any;
64+
expression?: any;
65+
arg?: string;
66+
modifiers?: { [key: string]: boolean };
6767
}

0 commit comments

Comments
 (0)