parent
fff62e2ee8
commit
1f2a652a9d
@ -10,7 +10,12 @@ import { Teleport, TeleportProps } from './components/Teleport'
|
|||||||
import { Suspense, SuspenseProps } from './components/Suspense'
|
import { Suspense, SuspenseProps } from './components/Suspense'
|
||||||
import { isObject, isArray } from '@vue/shared'
|
import { isObject, isArray } from '@vue/shared'
|
||||||
import { RawSlots } from './componentSlots'
|
import { RawSlots } from './componentSlots'
|
||||||
import { FunctionalComponent, Component, ComponentOptions } from './component'
|
import {
|
||||||
|
FunctionalComponent,
|
||||||
|
Component,
|
||||||
|
ComponentOptions,
|
||||||
|
ConcreteComponent
|
||||||
|
} from './component'
|
||||||
import { EmitsOptions } from './componentEmits'
|
import { EmitsOptions } from './componentEmits'
|
||||||
import { DefineComponent } from './apiDefineComponent'
|
import { DefineComponent } from './apiDefineComponent'
|
||||||
|
|
||||||
@ -112,6 +117,17 @@ export function h<P, E extends EmitsOptions = {}>(
|
|||||||
// catch-all for generic component types
|
// catch-all for generic component types
|
||||||
export function h(type: Component, children?: RawChildren): VNode
|
export function h(type: Component, children?: RawChildren): VNode
|
||||||
|
|
||||||
|
// concrete component
|
||||||
|
export function h<P>(
|
||||||
|
type: ConcreteComponent | string,
|
||||||
|
children?: RawChildren
|
||||||
|
): VNode
|
||||||
|
export function h<P>(
|
||||||
|
type: ConcreteComponent<P> | string,
|
||||||
|
props?: (RawProps & P) | ({} extends P ? null : never),
|
||||||
|
children?: RawChildren
|
||||||
|
): VNode
|
||||||
|
|
||||||
// component without props
|
// component without props
|
||||||
export function h(
|
export function h(
|
||||||
type: Component,
|
type: Component,
|
||||||
|
@ -16,9 +16,7 @@ const DIRECTIVES = 'directives'
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export function resolveComponent(
|
export function resolveComponent(name: string): ConcreteComponent | string {
|
||||||
name: string
|
|
||||||
): ConcreteComponent | string | undefined {
|
|
||||||
return resolveAsset(COMPONENTS, name) || name
|
return resolveAsset(COMPONENTS, name) || name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ import {
|
|||||||
Suspense,
|
Suspense,
|
||||||
Component,
|
Component,
|
||||||
expectError,
|
expectError,
|
||||||
expectAssignable
|
expectAssignable,
|
||||||
|
resolveComponent
|
||||||
} from './index'
|
} from './index'
|
||||||
|
|
||||||
describe('h inference w/ element', () => {
|
describe('h inference w/ element', () => {
|
||||||
@ -224,3 +225,11 @@ describe('Boolean prop implicit false', () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
expectError(h(RequiredComponent, {}))
|
expectError(h(RequiredComponent, {}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #2357
|
||||||
|
describe('resolveComponent should work', () => {
|
||||||
|
h(resolveComponent('test'))
|
||||||
|
h(resolveComponent('test'), {
|
||||||
|
message: '1'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user