diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index c235e30c388..d5cde0874fb 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -5,7 +5,12 @@ import { ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps } from './componentOptions' -import { SetupContext, RenderFunction, FunctionalComponent } from './component' +import { + SetupContext, + RenderFunction, + FunctionalComponent, + DefineComponent +} from './component' import { ComponentPublicInstance } from './componentProxy' import { ExtractPropTypes, ComponentPropsOptions } from './componentProps' import { EmitsOptions } from './componentEmits' @@ -59,7 +64,7 @@ export function defineComponent< E, VNodeProps & Props > -} & ComponentOptionsWithoutProps +} & DefineComponent //& ComponentOptionsWithoutProps // overload 3: object format with array props declaration // props inferred as { [key in PropNames]?: any } @@ -85,7 +90,7 @@ export function defineComponent< ): { // array props technically doesn't place any contraints on props in TSX new (): ComponentPublicInstance -} & ComponentOptionsWithArrayProps +} & DefineComponent //& ComponentOptionsWithArrayProps // overload 4: object format with object props declaration // see `ExtractPropTypes` in ./componentProps.ts @@ -119,7 +124,7 @@ export function defineComponent< E, VNodeProps & ExtractPropTypes > -} & ComponentOptionsWithObjectProps +} & DefineComponent //& ComponentOptionsBase // implementation, close to no-op export function defineComponent(options: unknown) { diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 2136ae791c6..32d5a4da9ce 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -71,7 +71,17 @@ export interface ClassComponent { __vccOpts: ComponentOptions } -export type Component = ComponentOptions | FunctionalComponent +// Allow typescript deferenciate DefineComponent from other interfaces +declare const DefineComponentSymbol: unique symbol +export interface DefineComponent { + [DefineComponentSymbol]: true + [key: string]: any +} + +export type Component = + | ComponentOptions + | FunctionalComponent + | DefineComponent // A type used in public APIs where a component type is expected. // The constructor type is an artificial type returned by defineComponent().