diff --git a/packages/language-core/src/generators/template.ts b/packages/language-core/src/generators/template.ts
index 4d1e83ddbc..3be6c675d9 100644
--- a/packages/language-core/src/generators/template.ts
+++ b/packages/language-core/src/generators/template.ts
@@ -685,16 +685,14 @@ export function generate(
else {
codes.push(
`const ${var_originalComponent} = ({} as `,
- `'${tag}' extends keyof typeof __VLS_ctx ? typeof __VLS_ctx : `,
);
for (const componentName of getPossibleOriginalComponentName(tag)) {
- codes.push(`'${componentName}' extends keyof typeof __VLS_ctx ? `);
- if (componentName === toCanonicalComponentName(tag)) {
- codes.push(`typeof __VLS_ctx : `);
- }
- else {
- codes.push(`{ [K in '${toCanonicalComponentName(tag)}']: typeof __VLS_ctx['${componentName}'] }: `);
- }
+ codes.push(
+ `'${componentName}' extends keyof typeof __VLS_ctx ? `,
+ `{ '${toCanonicalComponentName(tag)}': typeof __VLS_ctx`,
+ ...createPropertyAccessCode(componentName),
+ ` }: `,
+ );
}
codes.push(
`typeof __VLS_resolvedLocalAndGlobalComponents)`,
diff --git a/test-workspace/tsc/vue3/#3138/main.vue b/test-workspace/tsc/vue3/#3138/main.vue
index 9edcd2435f..02b4a75c0a 100644
--- a/test-workspace/tsc/vue3/#3138/main.vue
+++ b/test-workspace/tsc/vue3/#3138/main.vue
@@ -1,14 +1,15 @@
-
-
+
+