@@ -856,7 +856,12 @@ export function emitWebIdl(
856856 // A covariant EventHandler is one that is defined in a parent interface as then redefined in current interface with a more specific argument types
857857 // These patterns are unsafe, and flagged as error under --strictFunctionTypes.
858858 // Here we know the property is already defined on the interface, we elide its declaration if the parent has the same handler defined
859+ // Exception: if the property has an overrideType, we should emit it as an intentional override
859860 function isCovariantEventHandler ( i : Browser . Interface , p : Browser . Property ) {
861+ // If this property has an explicit overrideType, emit it (it's an intentional override)
862+ if ( p . overrideType ) {
863+ return false ;
864+ }
860865 return (
861866 isEventHandler ( p ) &&
862867 iNameToEhParents [ i . name ] . some ( ( parent ) =>
@@ -996,13 +1001,20 @@ export function emitWebIdl(
9961001 prefix : string ,
9971002 emitScope : EmitScope ,
9981003 i : Browser . Interface ,
1004+ emittedProperties ?: Set < string > ,
9991005 ) {
10001006 if ( i . properties ) {
10011007 mapToArray ( i . properties . property )
10021008 . filter ( ( m ) => matchScope ( emitScope , m ) )
10031009 . filter ( ( p ) => ! isCovariantEventHandler ( i , p ) )
1010+ . filter ( ( p ) => ! emittedProperties || ! emittedProperties . has ( p . name ) )
10041011 . sort ( compareName )
1005- . forEach ( ( p ) => emitProperty ( prefix , i , emitScope , p ) ) ;
1012+ . forEach ( ( p ) => {
1013+ emitProperty ( prefix , i , emitScope , p ) ;
1014+ if ( emittedProperties ) {
1015+ emittedProperties . add ( p . name ) ;
1016+ }
1017+ } ) ;
10061018 }
10071019 }
10081020
@@ -1148,11 +1160,12 @@ export function emitWebIdl(
11481160 prefix : string ,
11491161 emitScope : EmitScope ,
11501162 i : Browser . Interface ,
1163+ emittedProperties ?: Set < string > ,
11511164 ) {
11521165 const conflictedMembers = extendConflictsBaseTypes [ i . name ]
11531166 ? extendConflictsBaseTypes [ i . name ] . memberNames
11541167 : new Set < string > ( ) ;
1155- emitProperties ( prefix , emitScope , i ) ;
1168+ emitProperties ( prefix , emitScope , i , emittedProperties ) ;
11561169 const methodPrefix = prefix . startsWith ( "declare var" )
11571170 ? "declare function "
11581171 : "" ;
@@ -1164,13 +1177,21 @@ export function emitWebIdl(
11641177
11651178 /// Emit all members of every interfaces at the root level.
11661179 /// Called only once on the global polluter object
1167- function emitAllMembers ( i : Browser . Interface ) {
1168- emitMembers ( /*prefix*/ "declare var " , "InstanceOnly" , i ) ;
1180+ function emitAllMembers (
1181+ i : Browser . Interface ,
1182+ emittedProperties : Set < string > = new Set ( ) ,
1183+ ) {
1184+ emitMembers (
1185+ /*prefix*/ "declare var " ,
1186+ "InstanceOnly" ,
1187+ i ,
1188+ emittedProperties ,
1189+ ) ;
11691190
11701191 for ( const relatedIName of iNameToIDependList [ i . name ] ) {
11711192 const i = allInterfacesMap [ relatedIName ] ;
11721193 if ( i ) {
1173- emitAllMembers ( i ) ;
1194+ emitAllMembers ( i , emittedProperties ) ;
11741195 }
11751196 }
11761197 }
0 commit comments