@@ -115,20 +115,23 @@ export type ComponentInstance<T> = T extends { new (): ComponentPublicInstance }
115
115
: T extends FunctionalComponent < infer Props , infer Emits >
116
116
? ComponentPublicInstance < Props , { } , { } , { } , { } , ShortEmitsToObject < Emits > >
117
117
: T extends Component <
118
- infer Props ,
118
+ infer PropsOrInstance ,
119
119
infer RawBindings ,
120
120
infer D ,
121
121
infer C ,
122
122
infer M
123
123
>
124
- ? // NOTE we override Props/RawBindings/D to make sure is not `unknown`
125
- ComponentPublicInstance <
126
- unknown extends Props ? { } : Props ,
127
- unknown extends RawBindings ? { } : RawBindings ,
128
- unknown extends D ? { } : D ,
129
- C ,
130
- M
131
- >
124
+ ? PropsOrInstance extends { $props : unknown }
125
+ ? // T is returned by `defineComponent()`
126
+ PropsOrInstance
127
+ : // NOTE we override Props/RawBindings/D to make sure is not `unknown`
128
+ ComponentPublicInstance <
129
+ unknown extends PropsOrInstance ? { } : PropsOrInstance ,
130
+ unknown extends RawBindings ? { } : RawBindings ,
131
+ unknown extends D ? { } : D ,
132
+ C ,
133
+ M
134
+ >
132
135
: never // not a vue Component
133
136
134
137
/**
@@ -259,16 +262,16 @@ export type ConcreteComponent<
259
262
* The constructor type is an artificial type returned by defineComponent().
260
263
*/
261
264
export type Component <
262
- Props = any ,
265
+ PropsOrInstance = any ,
263
266
RawBindings = any ,
264
267
D = any ,
265
268
C extends ComputedOptions = ComputedOptions ,
266
269
M extends MethodOptions = MethodOptions ,
267
270
E extends EmitsOptions | Record < string , any [ ] > = { } ,
268
271
S extends Record < string , any > = any ,
269
272
> =
270
- | ConcreteComponent < Props , RawBindings , D , C , M , E , S >
271
- | ComponentPublicInstanceConstructor < Props >
273
+ | ConcreteComponent < PropsOrInstance , RawBindings , D , C , M , E , S >
274
+ | ComponentPublicInstanceConstructor < PropsOrInstance >
272
275
273
276
export type { ComponentOptions }
274
277
0 commit comments