Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly get components #3333

Merged
merged 11 commits into from Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/template.ts
Expand Up @@ -670,7 +670,7 @@ export function generate(
);
}
else if (componentVars[tag]) {
codes.push(`const ${var_originalComponent} = __VLS_templateComponents['${componentVars[tag]}'];\n`);
codes.push(`const ${var_originalComponent} = {} as __VLS_GetComponent<typeof __VLS_localComponents, __VLS_GlobalComponents, typeof __VLS_templateComponents, '${componentVars[tag]}'>;\n`);
}
else {
codes.push(`const ${var_originalComponent} = {} as any;\n`);
Expand Down
6 changes: 6 additions & 0 deletions packages/vue-language-core/src/utils/directorySharedTypes.ts
Expand Up @@ -29,6 +29,12 @@ type __VLS_GlobalComponents =
| 'Teleport'
>;

type __VLS_GetComponent<L, G, T, K> =
K extends keyof L ? L[K] :
K extends keyof G ? G[K] :
K extends keyof T ? T[K] :
any;

// v-for
declare function __VLS_getVForSourceType(source: number): [number, number, number][];
declare function __VLS_getVForSourceType(source: string): [string, number, number][];
Expand Down
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { exactType } from 'vue-tsc/shared';

declare module 'vue' {
export interface GlobalComponents {
FunctionalComponent: any;
}
}

declare const FunctionalComponent: new () => {
$slots: {
foo: (props: { bar: string }) => any;
}
};
</script>
<template>
<FunctionalComponent>
<template #foo="{ bar }">
{{ exactType(bar, '' as string) }}
</template>
</FunctionalComponent>
</template>
@@ -0,0 +1,11 @@
<script setup lang="ts">
declare module 'vue' {
export interface GlobalComponents {
Transition: typeof import('vue')['Transition'];
}
};
so1ve marked this conversation as resolved.
Show resolved Hide resolved
</script>

<template>
<Transition enter-active-class=""></Transition>
</template>