File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed
Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 288288 },
289289 "interfaces" : {
290290 "interface" : {
291- "GPUPipelineError" : {
292- // Web IDL optional argument can be followed by a required argument, but not in TS
293- // TODO: Maybe do this in the emitter?
294- "constructor" : {
295- "signature" : {
296- "0" : {
297- "param" : [
298- {
299- "name" : " message" ,
300- "optional" : false
301- }
302- ]
303- }
304- }
305- }
306- },
307291 "HTMLElement" : {
308292 "properties" : {
309293 "property" : {
Original file line number Diff line number Diff line change @@ -340,15 +340,29 @@ function convertCallbackFunctions(
340340 } ;
341341}
342342
343- function convertArgument ( arg : webidl2 . Argument ) : Browser . Param {
343+ function hasRequiredArgumentAfter ( arr : webidl2 . Argument [ ] , i : number ) : boolean {
344+ for ( let j = i + 1 ; j < arr . length ; j ++ ) {
345+ if ( ! arr [ j ] . optional && ! arr [ j ] . variadic ) {
346+ return true ;
347+ }
348+ }
349+ return false ;
350+ }
351+
352+ function convertArgument (
353+ arg : webidl2 . Argument ,
354+ i : number ,
355+ arr : webidl2 . Argument [ ] ,
356+ ) : Browser . Param {
344357 const idlType = convertIdlType ( arg . idlType ) ;
358+ const required = hasRequiredArgumentAfter ( arr , i ) ;
345359 if ( hasExtAttr ( arg . extAttrs , "LegacyNullToEmptyString" ) ) {
346360 idlType . nullable = true ;
347361 }
348362 return {
349363 name : arg . name ,
350364 ...idlType ,
351- optional : arg . optional ,
365+ optional : ! required && arg . optional ,
352366 variadic : arg . variadic ,
353367 allowShared : hasExtAttr ( arg . extAttrs , "AllowShared" ) ,
354368 } ;
You can’t perform that action at this time.
0 commit comments