@@ -31,6 +31,17 @@ const extendConflictsBaseTypes: Record<
3131 } ,
3232} ;
3333
34+ const extendConflictsInterfaces : Record <
35+ string ,
36+ { overrideMap : Record < string , string > }
37+ > = {
38+ HTMLElement : {
39+ overrideMap : {
40+ GlobalEventHandlers : 'Omit<GlobalEventHandlers, "onerror">' ,
41+ } ,
42+ } ,
43+ } ;
44+
3445// Namespaces that have been in form of interfaces for years
3546// and can't be converted to namespaces without breaking type packages
3647const namespacesAsInterfaces = [ "console" ] ;
@@ -1270,7 +1281,7 @@ export function emitWebIdl(
12701281 }
12711282
12721283 function processMixinName ( mixinName : string ) {
1273- if ( allInterfacesMap [ mixinName ] . typeParameters ?. length === 1 ) {
1284+ if ( allInterfacesMap [ mixinName ] ? .typeParameters ?. length === 1 ) {
12741285 return `${ mixinName } <${ i . name } >` ;
12751286 }
12761287 return mixinName ;
@@ -1293,11 +1304,27 @@ export function emitWebIdl(
12931304 `interface ${ getNameWithTypeParameters ( i . typeParameters , processedIName ) } ` ,
12941305 ) ;
12951306
1296- const finalExtends = [ i . extends || "Object" ]
1307+ // if (i.implements && extendConflictsInterfaces[i.name]?.implements?.length) {
1308+ // i.implements = extendConflictsInterfaces[i.name]?.implements;
1309+ // }
1310+
1311+ let finalExtends = [ i . extends || "Object" ]
12971312 . concat ( getImplementList ( i . name ) . map ( processMixinName ) )
1313+ // .concat(extendConflictsInterfaces[i.name]?.extendType ?? [])
12981314 . filter ( ( i ) => i !== "Object" )
12991315 . map ( processIName ) ;
13001316
1317+ if ( finalExtends . length && extendConflictsInterfaces [ i . name ] ?. overrideMap ) {
1318+ finalExtends = finalExtends . reduce ( ( agg , item ) => {
1319+ if ( extendConflictsInterfaces [ i . name ] ?. overrideMap [ item ] ) {
1320+ agg . push ( extendConflictsInterfaces [ i . name ] ?. overrideMap [ item ] ) ;
1321+ return agg ;
1322+ }
1323+ agg . push ( item ) ;
1324+ return agg ;
1325+ } , [ ] as string [ ] ) ;
1326+ }
1327+
13011328 if ( finalExtends . length ) {
13021329 printer . print ( ` extends ${ assertUnique ( finalExtends ) . join ( ", " ) } ` ) ;
13031330 }
0 commit comments