@@ -24,7 +24,7 @@ export function generateGlobalTypes({
2424 checkUnknownEvents,
2525 checkUnknownComponents,
2626} : VueCompilerOptions ) {
27- const fnPropsType = `(K extends { $props: infer Props } ? Props : any )${ checkUnknownProps ? '' : ' & Record<string, unknown>' } ` ;
27+ const fnPropsType = `(T extends { $props: infer Props } ? Props : {} )${ checkUnknownProps ? '' : ' & Record<string, unknown>' } ` ;
2828 let text = `` ;
2929 if ( target < 3.5 ) {
3030 text += `
@@ -68,10 +68,31 @@ export function generateGlobalTypes({
6868 N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
6969 N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
7070 ${ checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }' } ;
71- type __VLS_FunctionalComponentProps<T, K> =
72- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
73- : T extends (props: infer P, ...args: any) => any ? P :
74- {};
71+ type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
72+ ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
73+ , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
74+ >;
75+ type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}>
76+ ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
77+ : T extends (props: infer P, ...args: any) => any ? P
78+ : {};
79+ type __VLS_FunctionalComponent<T> = (props: ${ fnPropsType } , ctx?: any) => __VLS_Element & {
80+ __ctx?: {
81+ attrs?: any,
82+ slots?: T extends { ${ getSlotsPropertyName ( target ) } : infer Slots } ? Slots : Record<string, any>,
83+ emit?: T extends { $emit: infer Emit } ? Emit : {},
84+ props?: ${ fnPropsType } ,
85+ expose?: (exposed: T) => void,
86+ }
87+ };
88+ type __VLS_NormalizeSlotReturns<S, R = NonNullable<S> extends (...args: any) => infer K ? K : any> = R extends any[] ? {
89+ [K in keyof R]: R[K] extends infer V
90+ ? V extends Element ? V
91+ : V extends new (...args: any) => infer R ? ReturnType<__VLS_FunctionalComponent<R>>
92+ : V extends (...args: any) => infer R ? R
93+ : any
94+ : never
95+ } : R;
7596 type __VLS_IsFunction<T, K> = K extends keyof T
7697 ? __VLS_IsAny<T[K]> extends false
7798 ? unknown extends T[K]
@@ -118,10 +139,6 @@ export function generateGlobalTypes({
118139 NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
119140 > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
120141 type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
121- type __VLS_PickFunctionalComponentCtx<T, K> = NonNullable<__VLS_PickNotAny<
122- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
123- , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
124- >>;
125142 type __VLS_UseTemplateRef<T> = Readonly<import('${ lib } ').ShallowRef<T | null>>;
126143
127144 function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
@@ -146,19 +163,10 @@ export function generateGlobalTypes({
146163 : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
147164 function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
148165 function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
149- T extends new (...args: any) => any
150- ? (props: ${ fnPropsType } , ctx?: any) => __VLS_Element & {
151- __ctx?: {
152- attrs?: any;
153- slots?: K extends { ${ getSlotsPropertyName ( target ) } : infer Slots } ? Slots : any;
154- emit?: K extends { $emit: infer Emit } ? Emit : any;
155- expose?(exposed: K): void;
156- props?: ${ fnPropsType } ;
157- }
158- }
166+ T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
159167 : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
160168 : T extends (...args: any) => any ? T
161- : (_: {} ${ checkUnknownProps ? '' : ' & Record<string, unknown>' } , ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {} ${ checkUnknownProps ? '' : ' & Record<string, unknown>' } } } ;
169+ : __VLS_FunctionalComponent<{}> ;
162170 function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
163171 function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${ checkUnknownComponents ? '' : ' & Record<string, unknown>' } ) => void;
164172 function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
0 commit comments