Skip to content

Commit cc42b9b

Browse files
committed
chore(language-core): use object keys for originalPropName
1 parent 60352eb commit cc42b9b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export function* generateElementEvents(
3434
yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>${endOfLine}`;
3535
}
3636
const originalPropName = camelize('on-' + prop.arg.loc.source);
37+
const originalPropNameObjectKey = variableNameRegex.test(originalPropName)
38+
? originalPropName
39+
: `'${originalPropName}'`;
3740
yield `const ${ctx.getInternalVariable()}: `;
3841
if (!options.vueCompilerOptions.strictTemplates) {
3942
yield `Record<string, unknown> & `;
@@ -44,13 +47,13 @@ export function* generateElementEvents(
4447
yield `: __VLS_IsAny<typeof ${eventsVar}['${prop.arg.loc.source}']> extends false${newLine}`;
4548
yield `? {${newLine}`;
4649
yield `/**__VLS_emit,${emitVar},${prop.arg.loc.source}*/${newLine}`;
47-
yield `'${originalPropName}': typeof ${eventsVar}['${prop.arg.loc.source}']${newLine}`;
50+
yield `${originalPropNameObjectKey}: typeof ${eventsVar}['${prop.arg.loc.source}']${newLine}`;
4851
yield `}${newLine}`;
4952
if (prop.arg.loc.source !== camelize(prop.arg.loc.source)) {
5053
yield `: __VLS_IsAny<typeof ${eventsVar}['${camelize(prop.arg.loc.source)}']> extends false${newLine}`;
5154
yield `? {${newLine}`;
5255
yield `/**__VLS_emit,${emitVar},${camelize(prop.arg.loc.source)}*/${newLine}`;
53-
yield `'${originalPropName}': typeof ${eventsVar}['${camelize(prop.arg.loc.source)}']${newLine}`;
56+
yield `${originalPropNameObjectKey}: typeof ${eventsVar}['${camelize(prop.arg.loc.source)}']${newLine}`;
5457
yield `}${newLine}`;
5558
}
5659
yield `: typeof ${propsVar}${newLine}`;

0 commit comments

Comments
 (0)