From 2b7658dd63ca821130863a9126f9c0ec93fc8c19 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Sat, 31 Aug 2024 16:13:15 +0800 Subject: [PATCH] fix: type --- packages/language-core/lib/codegen/template/element.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/language-core/lib/codegen/template/element.ts b/packages/language-core/lib/codegen/template/element.ts index c4d715f461..7bae0f2b32 100644 --- a/packages/language-core/lib/codegen/template/element.ts +++ b/packages/language-core/lib/codegen/template/element.ts @@ -226,7 +226,7 @@ export function* generateComponent( const [refName, offset] = yield* generateVScope(options, ctx, node, props); if (refName) { const varName = ctx.getInternalVariable(); - options.templateRefNames.set(refName, [varName, offset]); + options.templateRefNames.set(refName, [varName, offset!]); ctx.usedComponentCtxVars.add(var_defineComponentCtx); yield `// @ts-ignore${newLine}`; @@ -334,7 +334,7 @@ export function* generateElement( const [refName, offset] = yield* generateVScope(options, ctx, node, node.props); if (refName) { - options.templateRefNames.set(refName, [`__VLS_intrinsicElements['${node.tag}']`, offset]); + options.templateRefNames.set(refName, [`__VLS_intrinsicElements['${node.tag}']`, offset!]); } const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot') as CompilerDOM.DirectiveNode; @@ -361,7 +361,7 @@ function* generateVScope( ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, props: (CompilerDOM.AttributeNode | CompilerDOM.DirectiveNode)[] -): Generator { +): Generator { const vScope = props.find(prop => prop.type === CompilerDOM.NodeTypes.DIRECTIVE && (prop.name === 'scope' || prop.name === 'data')); let inScope = false; let originalConditionsNum = ctx.blockConditions.length; @@ -541,7 +541,7 @@ function* generateReferencesForElements( options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode -): Generator { +): Generator { for (const prop of node.props) { if ( prop.type === CompilerDOM.NodeTypes.ATTRIBUTE @@ -569,6 +569,7 @@ function* generateReferencesForElements( return [content, startOffset]; } } + return []; } function* generateReferencesForScopedCssClasses(