From 9722d1be3fed0a697a296c48cdb76c758dcc3fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 1 Sep 2020 15:24:18 +0800 Subject: [PATCH] fix(runtime-core): fix `this` type of ComponentPublicInstance#$watch Type `this` of ComponentPublicInstance#watch should be `ComponentPublicInstance`, instead of `ComponentInternalInstance` which declared by `instanceWatch` --- packages/runtime-core/src/componentPublicInstance.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index 35125ac819a..c47941fc568 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -1,6 +1,6 @@ import { ComponentInternalInstance, Data } from './component' import { nextTick, queueJob } from './scheduler' -import { instanceWatch } from './apiWatch' +import { instanceWatch, WatchOptions, WatchStopHandle } from './apiWatch' import { EMPTY_OBJ, hasOwn, @@ -162,7 +162,11 @@ export type ComponentPublicInstance< $options: Options $forceUpdate: ReactiveEffect $nextTick: typeof nextTick - $watch: typeof instanceWatch + $watch( + source: string | Function, + cb: Function, + options?: WatchOptions + ): WatchStopHandle } & P & ShallowUnwrapRef & D &