Skip to content

Commit

Permalink
chore(language-core): code adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Apr 21, 2024
1 parent 74643b9 commit fa7a072
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 16 additions & 10 deletions packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -152,11 +155,14 @@ export function* generateElement(
yield `}, ...__VLS_functionalComponentArgsRest(${var_functionalComponent}))${endOfLine}`;
// and this for props type-checking
yield `({} as (props: __VLS_FunctionalComponentProps<typeof ${var_originalComponent}, typeof ${var_componentInstance}> & Record<string, unknown>) => 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}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fa7a072

Please sign in to comment.