@@ -11,9 +11,6 @@ export function getGlobalTypesFileName(options: VueCompilerOptions) {
1111export function generateGlobalTypes ( options : VueCompilerOptions ) {
1212 const { lib, target, checkUnknownProps } = options ;
1313
14- const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${
15- checkUnknownProps ? '' : ' & Record<string, unknown>'
16- } `;
1714 let text = `// @ts-nocheck\nexport {};\n` ;
1815 if ( target < 3.5 ) {
1916 text += `
@@ -24,6 +21,8 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
2421 }
2522 text += `
2623; declare global {
24+ var __VLS_unknownProps: ${ checkUnknownProps ? '{}' : 'Record<string, unknown>' } ;
25+
2726 const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any };
2827 const __VLS_unref: typeof import('${ lib } ').unref;
2928 const __VLS_placeholder: any;
@@ -32,7 +31,7 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
3231 ? `import('${ lib } /jsx-runtime').JSX.IntrinsicElements`
3332 : `globalThis.JSX.IntrinsicElements`
3433 } ;
35- var __VLS_CheckUnknownProps: ${ checkUnknownProps ? '{}' : 'Record<string, unknown>' } ;
34+
3635 type __VLS_Elements = __VLS_SpreadMerge<SVGElementTagNameMap, HTMLElementTagNameMap>;
3736 type __VLS_GlobalComponents = ${
3837 target >= 3.5
@@ -60,7 +59,7 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
6059 ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
6160 : T extends (props: infer P, ...args: any) => any ? P
6261 : {};
63- type __VLS_FunctionalComponent<T> = (props: ${ fnPropsType } , ctx?: any) => ${
62+ type __VLS_FunctionalComponent<T> = (props: (T extends { $props: infer Props } ? Props : {}) & typeof __VLS_unknownProps , ctx?: any) => ${
6463 target >= 3.3
6564 ? `import('${ lib } /jsx-runtime').JSX.Element`
6665 : `globalThis.JSX.Element`
@@ -69,7 +68,7 @@ export function generateGlobalTypes(options: VueCompilerOptions) {
6968 attrs?: any;
7069 slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>;
7170 emit?: T extends { $emit: infer Emit } ? Emit : {};
72- props?: ${ fnPropsType } ;
71+ props?: typeof props ;
7372 expose?: (exposed: T) => void;
7473 };
7574 };
0 commit comments