From fa7a072d603337c42d0bd3a8126c8213cf08e505 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Mon, 22 Apr 2024 05:19:25 +0900 Subject: [PATCH] chore(language-core): code adjust --- .../lib/codegen/template/element.ts | 26 ++++++++++++------- .../lib/codegen/template/elementProps.ts | 1 - 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/language-core/lib/codegen/template/element.ts b/packages/language-core/lib/codegen/template/element.ts index 1b0062ad8d..a29f3024a1 100644 --- a/packages/language-core/lib/codegen/template/element.ts +++ b/packages/language-core/lib/codegen/template/element.ts @@ -138,11 +138,14 @@ export function* generateElement( if (options.vueCompilerOptions.strictTemplates) { // with strictTemplates, generate once for props type-checking + instance type yield `const ${var_componentInstance} = ${var_functionalComponent}(`; - yield ['', 'template', startTagOffset, ctx.codeFeatures.verification]; - yield `{`; - yield* generateElementProps(options, ctx, node, props, 'normal', propsFailedExps); - yield `}`; - yield ['', 'template', startTagOffset + tag.length, ctx.codeFeatures.verification]; + yield* wrapWith( + startTagOffset, + startTagOffset + tag.length, + ctx.codeFeatures.verification, + `{`, + ...generateElementProps(options, ctx, node, props, 'normal', propsFailedExps), + `}`, + ); yield `, ...__VLS_functionalComponentArgsRest(${var_functionalComponent}))${endOfLine}`; } else { @@ -152,11 +155,14 @@ export function* generateElement( yield `}, ...__VLS_functionalComponentArgsRest(${var_functionalComponent}))${endOfLine}`; // and this for props type-checking yield `({} as (props: __VLS_FunctionalComponentProps & Record) => void)(`; - yield ['', 'template', startTagOffset, ctx.codeFeatures.verification]; - yield `{`; - yield* generateElementProps(options, ctx, node, props, 'normal', propsFailedExps); - yield `}`; - yield ['', 'template', startTagOffset + tag.length, ctx.codeFeatures.verification]; + yield* wrapWith( + startTagOffset, + startTagOffset + tag.length, + ctx.codeFeatures.verification, + `{`, + ...generateElementProps(options, ctx, node, props, 'normal', propsFailedExps), + `}`, + ); yield `)${endOfLine}`; } diff --git a/packages/language-core/lib/codegen/template/elementProps.ts b/packages/language-core/lib/codegen/template/elementProps.ts index 92d414a3e4..c5e9f4472a 100644 --- a/packages/language-core/lib/codegen/template/elementProps.ts +++ b/packages/language-core/lib/codegen/template/elementProps.ts @@ -291,7 +291,6 @@ function* generateAttrValue(attrNode: CompilerDOM.TextNode, features: VueCodeInf content = content.slice(1, -1); } if (needToUnicode(content)) { - yield ['', 'template', start, features]; yield* wrapWith( start, end,