Skip to content

Commit

Permalink
refactor: extract
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Aug 16, 2024
1 parent 0fb9f55 commit bf9781a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/language-core/lib/codegen/script/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getSlotsPropertyName } from '../../utils/shared';

export function generateGlobalTypes(vueCompilerOptions: VueCompilerOptions) {
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}`;
const fnEmitType = `K extends { $emit: infer Emit } ? ${vueCompilerOptions.strictTemplates ? 'Emit extends (event: infer E, ...args: any[]) => void ? __VLS_IsEqualStrict<E, string> extends true ? {} : Emit : any' : 'Emit'} : any`;
return `export const __VLS_globalTypesStart = {};
declare module '${vueCompilerOptions.lib}' {
interface GlobalComponents {}
Expand Down Expand Up @@ -78,7 +79,7 @@ declare global {
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
attrs?: any,
slots?: K extends { ${getSlotsPropertyName(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
emit?: K extends { $emit: infer Emit } ? ${vueCompilerOptions.strictTemplates ? 'Emit extends (event: infer E, ...args: any[]) => void ? __VLS_IsEqualStrict<E, string> extends true ? {} : Emit : any' : 'Emit'} : any
emit?: ${fnEmitType}
} & { props?: ${fnPropsType}; expose?(exposed: K): void; } }
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
: T extends (...args: any) => any ? T
Expand Down

0 comments on commit bf9781a

Please sign in to comment.