types: massive refactor

This commit is contained in:
Evan You
2019-10-22 11:26:48 -04:00
parent 522beaa766
commit b5886189ba
21 changed files with 308 additions and 258 deletions

View File

@@ -2,7 +2,12 @@ import { ComponentInternalInstance, Data, Emit } from './component'
import { nextTick } from './scheduler'
import { instanceWatch } from './apiWatch'
import { EMPTY_OBJ, hasOwn, isGloballyWhitelisted } from '@vue/shared'
import { ExtractComputedReturns } from './apiOptions'
import {
ExtractComputedReturns,
ComponentOptionsBase,
ComputedOptions,
MethodOptions
} from './apiOptions'
import { UnwrapRef, ReactiveEffect } from '@vue/reactivity'
import { warn } from './warning'
@@ -12,8 +17,8 @@ export type ComponentPublicInstance<
P = {},
B = {},
D = {},
C = {},
M = {},
C extends ComputedOptions = {},
M extends MethodOptions = {},
PublicProps = P
> = {
[key: string]: any
@@ -26,7 +31,7 @@ export type ComponentPublicInstance<
$parent: ComponentInternalInstance | null
$emit: Emit
$el: any
$options: any
$options: ComponentOptionsBase<P, B, D, C, M>
$forceUpdate: ReactiveEffect
$nextTick: typeof nextTick
$watch: typeof instanceWatch
@@ -134,7 +139,10 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
if (__RUNTIME_COMPILE__) {
// this trap is only called in browser-compiled render functions that use
// `with (this) {}`
PublicInstanceProxyHandlers.has = (_: any, key: string): boolean => {
PublicInstanceProxyHandlers.has = (
_: ComponentInternalInstance,
key: string
): boolean => {
return key[0] !== '_' && !isGloballyWhitelisted(key)
}
}