From ec55cce0866b7b7604efe097ca95a9ff94b62150 Mon Sep 17 00:00:00 2001 From: Bashamega <adambashaahmednaji@gmail.com> Date: Sat, 21 Jun 2025 09:57:37 +0300 Subject: [PATCH 1/2] Refactor property name handling in emitWebIdl function to support hyphenated names --- src/build/emitter.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/build/emitter.ts b/src/build/emitter.ts index 79654f016..180aef7c3 100644 --- a/src/build/emitter.ts +++ b/src/build/emitter.ts @@ -862,6 +862,7 @@ export function emitWebIdl( printer.printLine("/** @deprecated */"); printer.printLine("declare const name: void;"); } else { + const propertyName = p.name.includes("-") ? `"${p.name}"` : p.name; let pType: string; if (!p.overrideType && isEventHandler(p)) { // Sometimes event handlers with the same name may actually handle different @@ -884,7 +885,9 @@ export function emitWebIdl( const canPutForward = compilerBehavior.allowUnrelatedSetterType || !p.readonly; if (!prefix && canPutForward && p.putForwards) { - printer.printLine(`get ${p.name}${optionalModifier}(): ${pType};`); + printer.printLine( + `get ${propertyName}${optionalModifier}(): ${pType};`, + ); const forwardingProperty = getPropertyFromInterface( allInterfacesMap[pType], @@ -898,12 +901,12 @@ export function emitWebIdl( setterType += ` | ${pType}`; } printer.printLine( - `set ${p.name}${optionalModifier}(${p.putForwards}: ${setterType});`, + `set ${propertyName}${optionalModifier}(${p.putForwards}: ${setterType});`, ); } else { const readOnlyModifier = p.readonly && prefix === "" ? "readonly " : ""; printer.printLine( - `${prefix}${readOnlyModifier}${p.name}${optionalModifier}: ${pType};`, + `${prefix}${readOnlyModifier}${propertyName}${optionalModifier}: ${pType};`, ); } } From 8258a59f10e0aa0013e71b7caa7a0531ad613771 Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 22 Jun 2025 06:39:31 +0300 Subject: [PATCH 2/2] Update emitter.ts --- src/build/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/emitter.ts b/src/build/emitter.ts index 180aef7c3..14189ed17 100644 --- a/src/build/emitter.ts +++ b/src/build/emitter.ts @@ -862,7 +862,6 @@ export function emitWebIdl( printer.printLine("/** @deprecated */"); printer.printLine("declare const name: void;"); } else { - const propertyName = p.name.includes("-") ? `"${p.name}"` : p.name; let pType: string; if (!p.overrideType && isEventHandler(p)) { // Sometimes event handlers with the same name may actually handle different @@ -881,6 +880,7 @@ export function emitWebIdl( if (p.optional) { pType += " | undefined"; } + const propertyName = p.name.includes("-") ? `"${p.name}"` : p.name; const optionalModifier = !p.optional || prefix ? "" : "?"; const canPutForward = compilerBehavior.allowUnrelatedSetterType || !p.readonly;