From 3e7afc715463088576d6420f115c96dd959b6924 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Wed, 14 Aug 2019 18:20:50 +0400 Subject: [PATCH 1/3] Allow watch handler to be string as it is supported --- types/options.d.ts | 2 +- types/test/options-test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index 3fe7a9b7aaf..f438463e81d 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -177,7 +177,7 @@ export interface WatchOptions { } export interface WatchOptionsWithHandler extends WatchOptions { - handler: WatchHandler; + handler: WatchHandler | string; } export interface DirectiveBinding extends Readonly { diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 28060b7c817..d4ef99ae3d0 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -169,6 +169,10 @@ Vue.component('component', { this.a = val }, deep: true + }, + d: { + handler: 'someMethod', + immediate: true } }, el: "#app", From 300b6b5aeae380023978624ca327eb0a1f7c1b9e Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Wed, 14 Aug 2019 19:09:17 +0400 Subject: [PATCH 2/3] Move string type to WatchHandler itself --- types/options.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index f438463e81d..d48b1669341 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -169,7 +169,7 @@ export interface ComputedOptions { cache?: boolean; } -export type WatchHandler = (val: T, oldVal: T) => void; +export type WatchHandler = string | ((val: T, oldVal: T) => void); export interface WatchOptions { deep?: boolean; @@ -177,7 +177,7 @@ export interface WatchOptions { } export interface WatchOptionsWithHandler extends WatchOptions { - handler: WatchHandler | string; + handler: WatchHandler; } export interface DirectiveBinding extends Readonly { From 4003bbeb1e42fe51a5aa365e8244fe83c8d76e2a Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Wed, 14 Aug 2019 20:13:32 +0400 Subject: [PATCH 3/3] Removed string type as it moved to WatchHandler --- types/options.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index d48b1669341..aafe3c54b9e 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -76,7 +76,7 @@ export interface ComponentOptions< propsData?: object; computed?: Accessors; methods?: Methods; - watch?: Record | WatchHandler | string>; + watch?: Record | WatchHandler>; el?: Element | string; template?: string;