|
|
@@ -115,20 +115,23 @@ export type ComponentInstance<T> = T extends { new (): ComponentPublicInstance }
|
|
|
: T extends FunctionalComponent<infer Props, infer Emits>
|
|
|
? ComponentPublicInstance<Props, {}, {}, {}, {}, ShortEmitsToObject<Emits>>
|
|
|
: T extends Component<
|
|
|
- infer Props,
|
|
|
+ infer PropsOrInstance,
|
|
|
infer RawBindings,
|
|
|
infer D,
|
|
|
infer C,
|
|
|
infer M
|
|
|
>
|
|
|
- ? // NOTE we override Props/RawBindings/D to make sure is not `unknown`
|
|
|
- ComponentPublicInstance<
|
|
|
- unknown extends Props ? {} : Props,
|
|
|
- unknown extends RawBindings ? {} : RawBindings,
|
|
|
- unknown extends D ? {} : D,
|
|
|
- C,
|
|
|
- M
|
|
|
- >
|
|
|
+ ? PropsOrInstance extends { $props: unknown }
|
|
|
+ ? // T is returned by `defineComponent()`
|
|
|
+ PropsOrInstance
|
|
|
+ : // NOTE we override Props/RawBindings/D to make sure is not `unknown`
|
|
|
+ ComponentPublicInstance<
|
|
|
+ unknown extends PropsOrInstance ? {} : PropsOrInstance,
|
|
|
+ unknown extends RawBindings ? {} : RawBindings,
|
|
|
+ unknown extends D ? {} : D,
|
|
|
+ C,
|
|
|
+ M
|
|
|
+ >
|
|
|
: never // not a vue Component
|
|
|
|
|
|
/**
|
|
|
@@ -259,7 +262,7 @@ export type ConcreteComponent<
|
|
|
* The constructor type is an artificial type returned by defineComponent().
|
|
|
*/
|
|
|
export type Component<
|
|
|
- Props = any,
|
|
|
+ PropsOrInstance = any,
|
|
|
RawBindings = any,
|
|
|
D = any,
|
|
|
C extends ComputedOptions = ComputedOptions,
|
|
|
@@ -267,8 +270,8 @@ export type Component<
|
|
|
E extends EmitsOptions | Record<string, any[]> = {},
|
|
|
S extends Record<string, any> = any,
|
|
|
> =
|
|
|
- | ConcreteComponent<Props, RawBindings, D, C, M, E, S>
|
|
|
- | ComponentPublicInstanceConstructor<Props>
|
|
|
+ | ConcreteComponent<PropsOrInstance, RawBindings, D, C, M, E, S>
|
|
|
+ | ComponentPublicInstanceConstructor<PropsOrInstance>
|
|
|
|
|
|
export type { ComponentOptions }
|
|
|
|