Skip to content

Commit

Permalink
perf: Avoid doing type gymnastics with JSX.IntrinsicElements (#3259)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk authored Jun 8, 2023
1 parent dde8883 commit c667268
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function generate(

const data: Record<string, string> = {};

codes.push(`let __VLS_templateComponents!: {}\n`);
codes.push(`let __VLS_templateComponents!: __VLS_IntrinsicElements\n`);

for (const tagName in tagNames) {

Expand Down
12 changes: 5 additions & 7 deletions packages/vue-language-core/src/utils/directorySharedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
type __VLS_WithComponent<N0 extends string, Components, N1 extends string, N2 extends string, N3 extends string> =
__VLS_IsAny<__VLS_IntrinsicElements[N0]> extends true ? (
N1 extends keyof Components ? N1 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N1] } :
N2 extends keyof Components ? N2 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N2] } :
N3 extends keyof Components ? N3 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N3] } :
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: any }'}
) : Pick<__VLS_IntrinsicElements, N0>;
N1 extends keyof Components ? N1 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N1] } :
N2 extends keyof Components ? N2 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N2] } :
N3 extends keyof Components ? N3 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N3] } :
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
Expand Down Expand Up @@ -100,7 +98,7 @@ declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any)
}) => JSX.Element & { __ctx?: typeof ctx & { props?: typeof props; expose?(exposed: K): void; } }
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
: T extends (...args: any) => any ? T
: (_: T extends import('${vueCompilerOptions.lib}').VNode | import('${vueCompilerOptions.lib}').VNode[] | string ? {}: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: unknown, expose?: unknown, slots?: unknown, emit?: unknown, props?: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } }; // IntrinsicElement
: (_: T extends import('${vueCompilerOptions.lib}').VNode | import('${vueCompilerOptions.lib}').VNode[] | string ? {}: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } }; // IntrinsicElement
declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
declare function __VLS_pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): __VLS_FillingEventArg<
__VLS_PickNotAny<
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit c667268

Please sign in to comment.