Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/language-core/lib/codegen/template/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export function createTemplateCodegenContext(
}[] = [];
const emptyClassOffsets: number[] = [];
const inlayHints: InlayHintInfo[] = [];
const bindingAttrLocs: CompilerDOM.SourceLocation[] = [];
const inheritedAttrVars = new Set<string>();
const templateRefs = new Map<string, {
typeExp: string;
Expand Down Expand Up @@ -169,7 +168,6 @@ export function createTemplateCodegenContext(
scopedClasses,
emptyClassOffsets,
inlayHints,
bindingAttrLocs,
inheritedAttrVars,
templateRefs,
currentComponent: undefined as {
Expand Down
18 changes: 9 additions & 9 deletions packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { generateCamelized } from '../utils/camelized';
import type { TemplateCodegenContext } from './context';
import { generateElementDirectives } from './elementDirectives';
import { generateElementEvents } from './elementEvents';
import { type FailedPropExpression, generateElementProps } from './elementProps';
import { type FailGeneratedExpression, generateElementProps } from './elementProps';
import type { TemplateCodegenOptions } from './index';
import { generateInterpolation } from './interpolation';
import { generatePropertyAccess } from './propertyAccess';
Expand All @@ -27,7 +27,7 @@ export function* generateComponent(
node: CompilerDOM.ElementNode,
): Generator<Code> {
const tagOffsets = getElementTagOffsets(node, options.template);
const failedPropExps: FailedPropExpression[] = [];
const failGeneratedExpressions: FailGeneratedExpression[] = [];
const possibleOriginalNames = getPossibleOriginalComponentNames(node.tag, true);
const matchImportName = possibleOriginalNames.find(name => options.scriptSetupImportComponentNames.has(name));
const componentOriginalVar = matchImportName ?? ctx.getInternalVariable();
Expand Down Expand Up @@ -204,7 +204,7 @@ export function* generateComponent(
node,
props,
options.vueCompilerOptions.checkUnknownProps,
failedPropExps,
failGeneratedExpressions,
)];

yield `// @ts-ignore${newLine}`;
Expand All @@ -226,7 +226,7 @@ export function* generateComponent(
yield endBoundary(token2, tagOffsets[0] + node.tag.length);
yield `, ...__VLS_functionalComponentArgsRest(${componentFunctionalVar}))${endOfLine}`;

yield* generateFailedPropExps(options, ctx, failedPropExps);
yield* generateFailedExpressions(options, ctx, failGeneratedExpressions);
yield* generateElementEvents(
options,
ctx,
Expand Down Expand Up @@ -286,7 +286,7 @@ export function* generateElement(
node: CompilerDOM.ElementNode,
): Generator<Code> {
const [startTagOffset, endTagOffset] = getElementTagOffsets(node, options.template);
const failedPropExps: FailedPropExpression[] = [];
const failedPropExps: FailGeneratedExpression[] = [];

yield `__VLS_asFunctionalElement(__VLS_intrinsics`;
yield* generatePropertyAccess(
Expand Down Expand Up @@ -321,7 +321,7 @@ export function* generateElement(
yield endBoundary(token, startTagOffset + node.tag.length);
yield `)${endOfLine}`;

yield* generateFailedPropExps(options, ctx, failedPropExps);
yield* generateFailedExpressions(options, ctx, failedPropExps);
yield* generateElementDirectives(options, ctx, node);

const reference = yield* generateElementReference(options, ctx, node);
Expand Down Expand Up @@ -350,12 +350,12 @@ export function* generateElement(
ctx.currentComponent = currentComponent;
}

function* generateFailedPropExps(
function* generateFailedExpressions(
options: TemplateCodegenOptions,
ctx: TemplateCodegenContext,
failedPropExps: FailedPropExpression[],
failGeneratedExpressions: FailGeneratedExpression[],
): Generator<Code> {
for (const failedExp of failedPropExps) {
for (const failedExp of failGeneratedExpressions) {
yield* generateInterpolation(
options,
ctx,
Expand Down
14 changes: 7 additions & 7 deletions packages/language-core/lib/codegen/template/elementProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { TemplateCodegenOptions } from './index';
import { generateInterpolation } from './interpolation';
import { generateObjectProperty } from './objectProperty';

export interface FailedPropExpression {
export interface FailGeneratedExpression {
node: CompilerDOM.SimpleExpressionNode;
prefix: string;
suffix: string;
Expand All @@ -28,7 +28,7 @@ export function* generateElementProps(
node: CompilerDOM.ElementNode,
props: CompilerDOM.ElementNode['props'],
strictPropsCheck: boolean,
failedPropExps?: FailedPropExpression[],
failGeneratedExpressions?: FailGeneratedExpression[],
): Generator<Code> {
const isComponent = node.tagType === CompilerDOM.ElementTypes.COMPONENT;

Expand Down Expand Up @@ -60,14 +60,14 @@ export function* generateElementProps(
&& prop.arg.loc.source.startsWith('[')
&& prop.arg.loc.source.endsWith(']')
) {
failedPropExps?.push({ node: prop.arg, prefix: `(`, suffix: `)` });
failedPropExps?.push({ node: prop.exp, prefix: `() => {`, suffix: `}` });
failGeneratedExpressions?.push({ node: prop.arg, prefix: `(`, suffix: `)` });
failGeneratedExpressions?.push({ node: prop.exp, prefix: `() => {`, suffix: `}` });
}
else if (
!prop.arg
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
) {
failedPropExps?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
failGeneratedExpressions?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
}
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ export function* generateElementProps(
|| options.vueCompilerOptions.dataAttributes.some(pattern => isMatch(propName!, pattern))
) {
if (prop.exp && prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) {
failedPropExps?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
failGeneratedExpressions?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
}
continue;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ export function* generateElementProps(
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
) {
if (prop.exp.loc.source === '$attrs') {
ctx.bindingAttrLocs.push(prop.exp.loc);
failGeneratedExpressions?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
}
else {
const token = yield* startBoundary('template', prop.exp.loc.start.offset, codeFeatures.verification);
Expand Down
14 changes: 0 additions & 14 deletions packages/language-core/lib/codegen/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@ function* generateInheritedAttrs(
: `{}`
}`;
yield endOfLine;
if (ctx.bindingAttrLocs.length) {
yield `[`;
for (const loc of ctx.bindingAttrLocs) {
yield `__VLS_dollars.`;
yield [
loc.source,
'template',
loc.start.offset,
codeFeatures.all,
];
yield `,`;
}
yield `]${endOfLine}`;
}
return `import('${options.vueCompilerOptions.lib}').ComponentPublicInstance['$attrs'] & __VLS_InheritedAttrs`;
}

Expand Down
Loading