@@ -22,39 +22,22 @@ type DeepPartial<T> = T extends object
2222interface OverridableMethod extends Omit < Method , "signature" > {
2323 signature : DeepPartial < Signature > [ ] | Record < number , DeepPartial < Signature > > ;
2424}
25-
26- function optionalMember < const T > (
27- prop : string ,
28- type : T ,
29- value ?: Value | DeepPartial < WebIdl > ,
30- ) {
25+ function optionalMember < const T > ( prop : string , type : T , value ?: Value ) {
3126 if ( value === undefined ) {
3227 return { } ;
3328 }
34- // Support deep property assignment, e.g. prop = "a.b.c"
35- const propPath = prop . split ( "." ) ;
3629 if ( typeof value !== type ) {
3730 throw new Error ( `Expected type ${ value } for ${ prop } ` ) ;
3831 }
39- // If value is an object, ensure it is not empty (has at least one key)
40- if ( type === "object" && typeof value === "object" && value !== null ) {
41- if ( Object . keys ( value as object ) . length === 0 ) {
42- return { } ;
43- }
44- }
45-
46- // Build the nested object dynamically
47- let nested : any = value as T extends "string"
48- ? string
49- : T extends "number"
50- ? number
51- : T extends "boolean"
52- ? boolean
53- : never ;
54- for ( let i = propPath . length - 1 ; i >= 0 ; i -- ) {
55- nested = { [ propPath [ i ] ] : nested } ;
56- }
57- return nested ;
32+ return {
33+ [ prop ] : value as T extends "string"
34+ ? string
35+ : T extends "number"
36+ ? number
37+ : T extends "boolean"
38+ ? boolean
39+ : never ,
40+ } ;
5841}
5942
6043function string ( arg : unknown ) : string {
@@ -123,14 +106,10 @@ function convertKDLNodes(nodes: Node[]): DeepPartial<WebIdl> {
123106 }
124107
125108 return {
126- enums : {
127- enum : enums ,
128- } ,
129- dictionaries : {
130- dictionary,
131- } ,
132- ...optionalMember ( "mixins.mixin" , "object" , mixin ) ,
133- ...optionalMember ( "interfaces.interface" , "object" , interfaces ) ,
109+ enums : { enum : enums } ,
110+ mixins : { mixin } ,
111+ interfaces : { interface : interfaces } ,
112+ dictionaries : { dictionary } ,
134113 } ;
135114}
136115
@@ -467,7 +446,11 @@ export default async function readPatches(): Promise<{
467446 const patches = patchObjs . reduce ( ( acc , cur ) => merge ( acc , cur ) , { } ) ;
468447 const removalPatches = sanitizeRemovals (
469448 removalObjs . reduce ( ( acc , cur ) => merge ( acc , cur ) , { } ) ,
470- ) ;
449+ ) as DeepPartial < WebIdl > ;
450+
451+ // Only because we don't use them
452+ removalPatches . mixins = undefined ;
453+ removalPatches . interfaces = undefined ;
471454
472455 return { patches, removalPatches } ;
473456}
0 commit comments