Skip to content

Commit 9ece70d

Browse files
added clarifying comments
1 parent 9dffbc8 commit 9ece70d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/build/emitter.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ const extendConflictsBaseTypes: Record<
3131
},
3232
};
3333

34+
/**
35+
* There are situations where extended types properties or methods need
36+
* overridden by the implementing interface. Use this to register those interfaces
37+
* the key is the implementing interface, the override map key is the interface you want to override
38+
* the value overrides a type
39+
*/
3440
const extendConflictsInterfaces: Record<
3541
string,
3642
{ overrideMap: Record<string, string> }
@@ -1304,19 +1310,20 @@ export function emitWebIdl(
13041310
`interface ${getNameWithTypeParameters(i.typeParameters, processedIName)}`,
13051311
);
13061312

1307-
// if (i.implements && extendConflictsInterfaces[i.name]?.implements?.length) {
1308-
// i.implements = extendConflictsInterfaces[i.name]?.implements;
1309-
// }
1310-
1313+
// build the extends list for a given interface
13111314
let finalExtends = [i.extends || "Object"]
13121315
.concat(getImplementList(i.name).map(processMixinName))
1313-
// .concat(extendConflictsInterfaces[i.name]?.extendType ?? [])
13141316
.filter((i) => i !== "Object")
13151317
.map(processIName);
13161318

1319+
// overrides the interface's extends with any conflicts
1320+
// this is a separate filter to make sure we only override conflicts when
1321+
// they exist
13171322
if (finalExtends.length && extendConflictsInterfaces[i.name]?.overrideMap) {
13181323
finalExtends = finalExtends.reduce((agg, item) => {
1324+
// check for the conflict
13191325
if (extendConflictsInterfaces[i.name]?.overrideMap[item]) {
1326+
// overwrite the conflict
13201327
agg.push(extendConflictsInterfaces[i.name]?.overrideMap[item]);
13211328
return agg;
13221329
}

0 commit comments

Comments
 (0)