From 668e1e637461ff630803e85bf99158415d276d4c Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Mon, 21 Sep 2020 18:13:21 +0400 Subject: [PATCH] fix(types): allow string for watch handlers in options (#10396) * Allow watch handler to be string as it is supported * Move string type to WatchHandler itself * Removed string type as it moved to WatchHandler --- types/options.d.ts | 4 ++-- types/test/options-test.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index f49ca085e4e..323c7630986 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; @@ -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; diff --git a/types/test/options-test.ts b/types/test/options-test.ts index fb06abb583b..024916b4a70 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -168,6 +168,10 @@ Vue.component('component', { this.a = val }, deep: true + }, + d: { + handler: 'someMethod', + immediate: true } }, el: "#app",