From 064167002fd35874ae49df190484aefc1f43875c Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Tue, 24 Dec 2024 16:53:29 +0800 Subject: [PATCH] fix: intersect `__VLS_slots` with ... --- packages/language-core/lib/codegen/template/index.ts | 7 ++++--- test-workspace/tsc/passedFixtures/vue3/slots/main.vue | 11 +++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/language-core/lib/codegen/template/index.ts b/packages/language-core/lib/codegen/template/index.ts index 3b13f35395..7638cb8990 100644 --- a/packages/language-core/lib/codegen/template/index.ts +++ b/packages/language-core/lib/codegen/template/index.ts @@ -54,8 +54,10 @@ export function* generateTemplate(options: TemplateCodegenOptions): Generator { + const name = getSlotsPropertyName(options.vueCompilerOptions.target); + if (!options.hasDefineSlots) { - yield `var __VLS_slots!: `; + yield `var __VLS_slots!: typeof __VLS_ctx.${name} & `; for (const { expVar, varName } of ctx.dynamicSlots) { ctx.hasSlot = true; yield `Partial, (_: typeof ${varName}) => any>> &${newLine}`; @@ -85,8 +87,7 @@ function* generateSlots(options: TemplateCodegenOptions, ctx: TemplateCodegenCon } yield `}${endOfLine}`; } - const name = getSlotsPropertyName(options.vueCompilerOptions.target); - yield `var ${name}!: typeof __VLS_ctx.${name} & typeof ${options.slotsAssignName ?? '__VLS_slots'}${endOfLine}`; + yield `var ${name}!: typeof ${options.slotsAssignName ?? '__VLS_slots'}${endOfLine}`; } function* generateInheritedAttrs(ctx: TemplateCodegenContext): Generator { diff --git a/test-workspace/tsc/passedFixtures/vue3/slots/main.vue b/test-workspace/tsc/passedFixtures/vue3/slots/main.vue index e02d348208..4a401fcf27 100644 --- a/test-workspace/tsc/passedFixtures/vue3/slots/main.vue +++ b/test-workspace/tsc/passedFixtures/vue3/slots/main.vue @@ -1,7 +1,4 @@