types: adjust resolveDynamicComponent return type

This commit is contained in:
Evan You 2020-07-07 12:43:05 -04:00
parent d5ab70ba66
commit fe9e227ae4

View File

@ -3,6 +3,7 @@ import { currentInstance, Component, FunctionalComponent } from '../component'
import { Directive } from '../directives' import { Directive } from '../directives'
import { camelize, capitalize, isString } from '@vue/shared' import { camelize, capitalize, isString } from '@vue/shared'
import { warn } from '../warning' import { warn } from '../warning'
import { VNodeTypes } from '../vnode'
const COMPONENTS = 'components' const COMPONENTS = 'components'
const DIRECTIVES = 'directives' const DIRECTIVES = 'directives'
@ -19,14 +20,12 @@ export const NULL_DYNAMIC_COMPONENT = Symbol()
/** /**
* @private * @private
*/ */
export function resolveDynamicComponent( export function resolveDynamicComponent(component: unknown): VNodeTypes {
component: unknown
): Component | string | typeof NULL_DYNAMIC_COMPONENT {
if (isString(component)) { if (isString(component)) {
return resolveAsset(COMPONENTS, component, false) || component return resolveAsset(COMPONENTS, component, false) || component
} else { } else {
// invalid types will fallthrough to createVNode and raise warning // invalid types will fallthrough to createVNode and raise warning
return (component as any) || NULL_DYNAMIC_COMPONENT return (component || NULL_DYNAMIC_COMPONENT) as any
} }
} }