From 68cd48e56207df2ebf9d57e3b2745ba0ce2c395a Mon Sep 17 00:00:00 2001 From: Kael Date: Wed, 11 Apr 2018 20:18:21 +1000 Subject: [PATCH 1/4] fix(types): make VNodeDirective properties optional --- types/test/options-test.ts | 4 ++++ types/vnode.d.ts | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 6fc9e356451..7df3250c1a4 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -142,6 +142,10 @@ Vue.component('component', { props: { myProp: "bar" }, + directives: [{ + name: 'a', + value: 'foo' + }], domProps: { innerHTML: "baz" }, diff --git a/types/vnode.d.ts b/types/vnode.d.ts index 5754c433dcd..586a3842b64 100644 --- a/types/vnode.d.ts +++ b/types/vnode.d.ts @@ -59,9 +59,9 @@ export interface VNodeData { export interface VNodeDirective { readonly name: string; - readonly value: any; - readonly oldValue: any; - readonly expression: any; - readonly arg: string; - readonly modifiers: { [key: string]: boolean }; + readonly value?: any; + readonly oldValue?: any; + readonly expression?: any; + readonly arg?: string; + readonly modifiers?: { [key: string]: boolean }; } From 7ee7738f8787993e9cd3c1cb75c53fd73875bd81 Mon Sep 17 00:00:00 2001 From: Kael Date: Wed, 11 Apr 2018 20:46:34 +1000 Subject: [PATCH 2/4] fix(types): create a separate interface for DirectiveBinding --- types/options.d.ts | 13 ++++++++++++- types/vnode.d.ts | 12 ++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index cc58affe6a1..00ac467d9b5 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -160,9 +160,20 @@ export interface WatchOptionsWithHandler extends WatchOptions { handler: WatchHandler; } +export interface DirectiveBinding { + readonly name: string; + readonly rawName: string; + readonly def: DirectiveOptions; + readonly value: any; + readonly oldValue: any; + readonly expression: any; + readonly arg: string; + readonly modifiers: { [key: string]: boolean }; +} + export type DirectiveFunction = ( el: HTMLElement, - binding: VNodeDirective, + binding: DirectiveBinding, vnode: VNode, oldVnode: VNode ) => void; diff --git a/types/vnode.d.ts b/types/vnode.d.ts index 586a3842b64..9247c474575 100644 --- a/types/vnode.d.ts +++ b/types/vnode.d.ts @@ -58,10 +58,10 @@ export interface VNodeData { } export interface VNodeDirective { - readonly name: string; - readonly value?: any; - readonly oldValue?: any; - readonly expression?: any; - readonly arg?: string; - readonly modifiers?: { [key: string]: boolean }; + name: string; + value?: any; + oldValue?: any; + expression?: any; + arg?: string; + modifiers?: { [key: string]: boolean }; } From 8523bb098573e9230c507fda26b3f80e82fd8372 Mon Sep 17 00:00:00 2001 From: Kael Date: Fri, 13 Apr 2018 22:21:40 +1000 Subject: [PATCH 3/4] refactor(types): only use a single definition for VNodeDirective --- types/options.d.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 00ac467d9b5..91dee285695 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -160,20 +160,9 @@ export interface WatchOptionsWithHandler extends WatchOptions { handler: WatchHandler; } -export interface DirectiveBinding { - readonly name: string; - readonly rawName: string; - readonly def: DirectiveOptions; - readonly value: any; - readonly oldValue: any; - readonly expression: any; - readonly arg: string; - readonly modifiers: { [key: string]: boolean }; -} - export type DirectiveFunction = ( el: HTMLElement, - binding: DirectiveBinding, + binding: Readonly, vnode: VNode, oldVnode: VNode ) => void; From 152441bc4424089052b10b6252eefd4445ab43a5 Mon Sep 17 00:00:00 2001 From: Kael Date: Fri, 13 Apr 2018 22:39:33 +1000 Subject: [PATCH 4/4] fix(types): binding.modifiers is always defined --- types/options.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index 91dee285695..d0e7adac386 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -160,9 +160,13 @@ export interface WatchOptionsWithHandler extends WatchOptions { handler: WatchHandler; } +export interface DirectiveBinding extends Readonly { + readonly modifiers: { [key: string]: boolean }; +} + export type DirectiveFunction = ( el: HTMLElement, - binding: Readonly, + binding: DirectiveBinding, vnode: VNode, oldVnode: VNode ) => void;