Skip to content

Switch from JSON to KDL format #2056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Next Next commit
Refactor property name handling in emitWebIdl function to support hyp…
…henated names
  • Loading branch information
Bashamega committed Jun 21, 2025
commit ec55cce0866b7b7604efe097ca95a9ff94b62150
9 changes: 6 additions & 3 deletions src/build/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand All @@ -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};`,
);
}
}
Expand Down