1+ import type { VueCompilerOptions } from '../types' ;
12import { getSlotsPropertyName } from '../utils/shared' ;
23
3- export function generateGlobalTypes ( lib : string , target : number , strictTemplates : boolean ) {
4- const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${ strictTemplates ? '' : ' & Record<string, unknown>' } ` ;
4+ export function resolveGlobalTypesName ( options : VueCompilerOptions ) {
5+ const { lib, target, strictTemplates } = options ;
6+ return `${ lib } _${ target } _${ strictTemplates . attributes } _${ strictTemplates . components } .d.ts` ;
7+ }
8+
9+ export function generateGlobalTypes ( options : VueCompilerOptions ) {
10+ const { lib, target, strictTemplates } = options ;
11+ const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${ strictTemplates . attributes ? '' : ' & Record<string, unknown>' } ` ;
512 let text = `` ;
613 if ( target < 3.5 ) {
714 text += `
@@ -49,7 +56,7 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
4956 N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
5057 N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
5158 N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
52- ${ strictTemplates ? '{}' : '{ [K in N0]: unknown }' } ;
59+ ${ strictTemplates . components ? '{}' : '{ [K in N0]: unknown }' } ;
5360 type __VLS_FunctionalComponentProps<T, K> =
5461 '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
5562 : T extends (props: infer P, ...args: any) => any ? P :
@@ -69,7 +76,7 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
6976 : __VLS_IsFunction<Events, CamelizedEvent> extends true
7077 ? { [K in onEvent]?: Events[CamelizedEvent] }
7178 : Props
72- )${ strictTemplates ? '' : ' & Record<string, unknown>' } ;
79+ )${ strictTemplates . attributes ? '' : ' & Record<string, unknown>' } ;
7380 // fix https://github.com/vuejs/language-tools/issues/926
7481 type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
7582 type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
@@ -143,8 +150,8 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
143150 } & { props?: ${ fnPropsType } ; expose?(exposed: K): void; } }
144151 : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
145152 : T extends (...args: any) => any ? T
146- : (_: {}${ strictTemplates ? '' : ' & Record<string, unknown>' } , ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${ strictTemplates ? '' : ' & Record<string, unknown>' } } };
147- function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (_: T${ strictTemplates ? '' : ' & Record<string, unknown>' } ) => void;
153+ : (_: {}${ strictTemplates . attributes ? '' : ' & Record<string, unknown>' } , ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${ strictTemplates . attributes ? '' : ' & Record<string, unknown>' } } };
154+ function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (_: T${ strictTemplates . components ? '' : ' & Record<string, unknown>' } ) => void;
148155 function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
149156 function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
150157 function __VLS_tryAsConstant<const T>(t: T): T;
0 commit comments