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:
Evan You
2020-08-19 16:11:29 -04:00
parent 4baf852a34
commit eb2ae44d94
21 changed files with 117 additions and 102 deletions

View File

@@ -3,8 +3,8 @@ import {
Data,
SetupContext,
ComponentInternalOptions,
PublicAPIComponent,
Component,
ConcreteComponent,
InternalRenderFunction
} from './component'
import {
@@ -52,7 +52,7 @@ import { Directive } from './directives'
import {
CreateComponentPublicInstance,
ComponentPublicInstance
} from './componentProxy'
} from './componentPublicInstance'
import { warn } from './warning'
import { VNodeChild } from './vnode'
@@ -103,7 +103,7 @@ export interface ComponentOptionsBase<
// Luckily `render()` doesn't need any arguments nor does it care about return
// type.
render?: Function
components?: Record<string, PublicAPIComponent>
components?: Record<string, Component>
directives?: Record<string, Directive>
inheritAttrs?: boolean
emits?: (E | EE[]) & ThisType<void>
@@ -132,7 +132,7 @@ export interface ComponentOptionsBase<
* marker for AsyncComponentWrapper
* @internal
*/
__asyncLoader?: () => Promise<Component>
__asyncLoader?: () => Promise<ConcreteComponent>
/**
* cache for merged $options
* @internal