Skip to content

Commit 5376f99

Browse files
committed
fix(language-core): generate camelized event name for emit reference
1 parent fe54421 commit 5376f99

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/language-core/lib/codegen/template/elementEvents.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { wrapWith } from '../utils/wrapWith';
88
import type { TemplateCodegenContext } from './context';
99
import type { TemplateCodegenOptions } from './index';
1010
import { generateInterpolation } from './interpolation';
11-
import { generatePropertyAccess } from './propertyAccess';
11+
import { generateObjectProperty } from './objectProperty';
1212

1313
export function* generateElementEvents(
1414
options: TemplateCodegenOptions,
@@ -54,16 +54,21 @@ export function* generateElementEvents(
5454
propPrefix = 'onVnode-';
5555
emitPrefix = 'vnode-';
5656
}
57-
yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${camelize(propPrefix + source)}', '${emitPrefix + source}', '${camelize(emitPrefix + source)}'> => (`;
58-
yield emitsVar;
59-
yield* generatePropertyAccess(
60-
options,
61-
ctx,
62-
emitPrefix + source,
63-
start,
64-
ctx.codeFeatures.navigation
65-
);
66-
yield `, {${newLine}`;
57+
yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${camelize(propPrefix + source)}', '${emitPrefix + source}', '${camelize(emitPrefix + source)}'> => (${newLine}`;
58+
if (prop.name === 'on') {
59+
yield `{ `;
60+
yield* generateObjectProperty(
61+
options,
62+
ctx,
63+
emitPrefix + source,
64+
start!,
65+
ctx.codeFeatures.navigation,
66+
undefined,
67+
true
68+
);
69+
yield `: {} as any } as typeof ${emitsVar},${newLine}`;
70+
}
71+
yield `{ `;
6772
if (prop.name === 'on') {
6873
yield* generateEventArg(ctx, source, start!, propPrefix.slice(0, -1));
6974
yield `: `;

0 commit comments

Comments
 (0)