diff --git a/packages/language-core/lib/codegen/template/context.ts b/packages/language-core/lib/codegen/template/context.ts index c5abab54e1..7334ae85a3 100644 --- a/packages/language-core/lib/codegen/template/context.ts +++ b/packages/language-core/lib/codegen/template/context.ts @@ -63,6 +63,10 @@ export function createTemplateCodegenContext(options: Pick { + if (ctx.lastGenericComment) { + const { content, offset } = ctx.lastGenericComment; + yield* wrapWith( + offset, + offset + content.length, + ctx.codeFeatures.verification, + `<`, + [ + content, + 'template', + offset, + ctx.codeFeatures.all + ], + `>` + ); + } + ctx.lastGenericComment = undefined; +} + function* generateComponentSlot( options: TemplateCodegenOptions, ctx: TemplateCodegenContext, diff --git a/packages/language-core/lib/codegen/template/elementDirectives.ts b/packages/language-core/lib/codegen/template/elementDirectives.ts index 3c67bce054..c8ebf4758a 100644 --- a/packages/language-core/lib/codegen/template/elementDirectives.ts +++ b/packages/language-core/lib/codegen/template/elementDirectives.ts @@ -24,6 +24,7 @@ export function* generateElementDirectives( || prop.name === 'bind' || prop.name === 'scope' || prop.name === 'data' + || prop.name === 'generic' ) { continue; } diff --git a/packages/language-core/lib/codegen/template/templateChild.ts b/packages/language-core/lib/codegen/template/templateChild.ts index c7df01b522..69be101239 100644 --- a/packages/language-core/lib/codegen/template/templateChild.ts +++ b/packages/language-core/lib/codegen/template/templateChild.ts @@ -36,16 +36,26 @@ export function* generateTemplateChild( ): Generator { if (prevNode?.type === CompilerDOM.NodeTypes.COMMENT) { const commentText = prevNode.content.trim().split(' ')[0]; - if (commentText.match(/^@vue-skip\b[\s\S]*/)) { + if (/^@vue-skip\b[\s\S]*/.test(commentText)) { yield `// @vue-skip${newLine}`; return; } - else if (commentText.match(/^@vue-ignore\b[\s\S]*/)) { + else if (/^@vue-ignore\b[\s\S]*/.test(commentText)) { yield* ctx.ignoreError(); } - else if (commentText.match(/^@vue-expect-error\b[\s\S]*/)) { + else if (/^@vue-expect-error\b[\s\S]*/.test(commentText)) { yield* ctx.expectError(prevNode); } + else { + const match = prevNode.loc.source.match(/^ + + + + + + +