We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fad5aab commit 09f611bCopy full SHA for 09f611b
1 file changed
src/build/emitter.ts
@@ -1580,9 +1580,11 @@ export function emitWebIdl(
1580
.sort(compareName)
1581
.forEach((m) => {
1582
emitComments(m, printer.printLine);
1583
- printer.printLine(
1584
- `${m.name}${m.required ? "" : "?"}: ${convertDomTypeToTsType(m)};`,
1585
- );
+ let type = convertDomTypeToTsType(m);
+ if (!m.required && !type.split(" | ").includes("undefined")) {
+ type += " | undefined";
1586
+ }
1587
+ printer.printLine(`${m.name}${m.required ? "" : "?"}: ${type};`);
1588
});
1589
}
1590
if (dict.overrideIndexSignatures) {
0 commit comments