types: add missing properties to ComponentPublicInstance interface (#218)

This commit is contained in:
Cr 2019-10-12 22:30:21 +08:00 committed by Evan You
parent 4a100828de
commit f3760f7d34
2 changed files with 7 additions and 2 deletions

View File

@ -209,7 +209,7 @@ export function instanceWatch(
source: string | Function, source: string | Function,
cb: Function, cb: Function,
options?: WatchOptions options?: WatchOptions
): () => void { ): StopHandle {
const ctx = this.renderProxy! const ctx = this.renderProxy!
const getter = isString(source) ? () => ctx[source] : source.bind(ctx) const getter = isString(source) ? () => ctx[source] : source.bind(ctx)
const stop = watch(getter, cb.bind(ctx), options) const stop = watch(getter, cb.bind(ctx), options)

View File

@ -3,7 +3,7 @@ import { nextTick } from './scheduler'
import { instanceWatch } from './apiWatch' import { instanceWatch } from './apiWatch'
import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared' import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared'
import { ExtractComputedReturns } from './apiOptions' import { ExtractComputedReturns } from './apiOptions'
import { UnwrapRef } from '@vue/reactivity' import { UnwrapRef, ReactiveEffect } from '@vue/reactivity'
import { warn } from './warning' import { warn } from './warning'
// public properties exposed on the proxy, which is used as the render context // public properties exposed on the proxy, which is used as the render context
@ -25,6 +25,11 @@ export type ComponentPublicInstance<
$root: ComponentInternalInstance | null $root: ComponentInternalInstance | null
$parent: ComponentInternalInstance | null $parent: ComponentInternalInstance | null
$emit: (event: string, ...args: unknown[]) => void $emit: (event: string, ...args: unknown[]) => void
$el: any
$options: any
$forceUpdate: ReactiveEffect
$nextTick: typeof nextTick
$watch: typeof instanceWatch
} & P & } & P &
UnwrapRef<B> & UnwrapRef<B> &
D & D &