Skip to content

Commit 9e2aaf7

Browse files
committed
fix(language-core): fallthroughAttributes causes global components to be self-referential
close #4761
1 parent 8d8e069 commit 9e2aaf7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/language-core/lib/codegen/script/template.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,17 @@ export function* generateTemplateComponents(options: ScriptCodegenOptions): Gene
102102
}
103103

104104
exps.push(`{} as NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}>`);
105-
exps.push(`{} as __VLS_GlobalComponents`);
106105
exps.push(`__VLS_ctxBase`);
107106

108-
yield `const __VLS_components = {${newLine}`;
107+
yield `const __VLS_localComponents = {${newLine}`;
109108
for (const type of exps) {
110109
yield `...`;
111110
yield type;
112111
yield `,${newLine}`;
113112
}
114113
yield `}${endOfLine}`;
114+
115+
yield `let __VLS_components: typeof __VLS_localComponents & __VLS_GlobalComponents${endOfLine}`;
115116
}
116117

117118
export function* generateTemplate(

packages/language-core/lib/codegen/template/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function* generateTemplate(options: TemplateCodegenOptions): Generator<Co
125125
}
126126
components.add(node.tag);
127127
yield newLine;
128-
yield ` & __VLS_WithComponent<'${getCanonicalComponentName(node.tag)}', typeof __VLS_components, `;
128+
yield ` & __VLS_WithComponent<'${getCanonicalComponentName(node.tag)}', typeof __VLS_localComponents, `;
129129
yield getPossibleOriginalComponentNames(node.tag, false)
130130
.map(name => `"${name}"`)
131131
.join(', ');

0 commit comments

Comments
 (0)