refactor: adjust internal vnode types + more dts tests

This commit is contained in:
Evan You
2019-11-04 18:38:55 -05:00
parent 957d3a0547
commit dfc7c0f12a
23 changed files with 489 additions and 318 deletions

View File

@@ -13,7 +13,7 @@ import { onBeforeUnmount, injectHook, onUnmounted } from '../apiLifecycle'
import { isString, isArray } from '@vue/shared'
import { watch } from '../apiWatch'
import { ShapeFlags } from '../shapeFlags'
import { SuspenseBoundary } from '../rendererSuspense'
import { SuspenseBoundary } from './Suspense'
import {
RendererInternals,
queuePostRenderEffect,
@@ -39,7 +39,7 @@ export interface KeepAliveSink {
deactivate: (vnode: VNode) => void
}
export const KeepAlive = {
const KeepAliveImpl = {
name: `KeepAlive`,
// Marker for special handling inside the renderer. We are not using a ===
@@ -201,13 +201,20 @@ export const KeepAlive = {
}
if (__DEV__) {
;(KeepAlive as any).props = {
;(KeepAliveImpl as any).props = {
include: [String, RegExp, Array],
exclude: [String, RegExp, Array],
max: [String, Number]
}
}
// export the public type for h/tsx inference
export const KeepAlive = (KeepAliveImpl as any) as {
new (): {
$props: KeepAliveProps
}
}
function getName(comp: Component): string | void {
return (comp as FunctionalComponent).displayName || comp.name
}
@@ -268,7 +275,7 @@ function registerKeepAliveHook(
if (target) {
let current = target.parent
while (current && current.parent) {
if (current.parent.type === KeepAlive) {
if (current.parent.type === KeepAliveImpl) {
injectToKeepAliveRoot(wrappedHook, type, target, current)
}
current = current.parent