From 4693383e568ff6aa3f3538e9c8879a504fbab905 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Mon, 23 Dec 2024 13:22:10 +0800 Subject: [PATCH] fix(language-core): map `v-slot` correctly to report error when missing default slot --- .../language-core/lib/codegen/template/element.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/language-core/lib/codegen/template/element.ts b/packages/language-core/lib/codegen/template/element.ts index 9fbeccca69..ad08c45cf1 100644 --- a/packages/language-core/lib/codegen/template/element.ts +++ b/packages/language-core/lib/codegen/template/element.ts @@ -495,24 +495,16 @@ function* generateComponentSlot( false, true ); - yield ': __VLS_thisSlot'; } else { - yield `default: `; yield* wrapWith( slotDir.loc.start.offset, - slotDir.loc.start.offset + ( - slotDir.loc.source.startsWith('#') - ? '#'.length - : slotDir.loc.source.startsWith('v-slot:') - ? 'v-slot:'.length - : 0 - ), + slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0), ctx.codeFeatures.withoutHighlightAndCompletion, - `__VLS_thisSlot` + `default` ); } - yield `} = ${componentCtxVar}.slots!${endOfLine}`; + yield `: __VLS_thisSlot } = ${componentCtxVar}.slots!${endOfLine}`; if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { const slotAst = createTsAst(options.ts, slotDir, `(${slotDir.exp.content}) => {}`);