refactor(types): widen Component type to include consutructor types
returned from `defineComponent` ref: https://github.com/vuejs/vue-router-next/pull/421 also close #1880 Previous `Component` type is now exported as `ConcreteComponent`. This introduces a minor breaking change when calling `h(comp, { ... })` will now fail if `comp` is a of generic `Component` type, since it does not specify what props it expects.
This commit is contained in:
@@ -68,11 +68,6 @@ interface Constructor<P = any> {
|
||||
new (): { $props: P }
|
||||
}
|
||||
|
||||
// Excludes Component type from returned `defineComponent`
|
||||
type NotDefinedComponent<T extends Component> = T extends Constructor
|
||||
? never
|
||||
: T
|
||||
|
||||
// The following is a series of overloads for providing props validation of
|
||||
// manually written render functions.
|
||||
|
||||
@@ -117,9 +112,9 @@ export function h<P, E extends EmitsOptions = {}>(
|
||||
// catch-all for generic component types
|
||||
export function h(type: Component, children?: RawChildren): VNode
|
||||
|
||||
// exclude `defineComponent`
|
||||
export function h<Options extends ComponentOptions | FunctionalComponent<{}>>(
|
||||
type: NotDefinedComponent<Options>,
|
||||
// exclude `defineComponent` constructors
|
||||
export function h<T extends ComponentOptions | FunctionalComponent<{}>>(
|
||||
type: T,
|
||||
props?: RawProps | null,
|
||||
children?: RawChildren | RawSlots
|
||||
): VNode
|
||||
|
||||
Reference in New Issue
Block a user