@@ -465,17 +465,33 @@ let EmitStaticInterface flavor (i:Browser.Interface) =
465
465
// Some types are static types with non-static members. For example,
466
466
// NodeFilter is a static method itself, however it has an "acceptNode" method
467
467
// that expects the user to implement.
468
- let hasNonStaticMember =
469
- match i.Methods with
470
- | Some ms -> ms.Methods |> Array.exists ( fun m -> m.Static.IsNone)
471
- | _ -> false
468
+ let hasNonStaticMember =
469
+ let hasNonStaticMethod =
470
+ match JsonItems.getAddedItemsByInterfaceName ItemKind.Method flavor i.Name with
471
+ | [||] ->
472
+ match i.Methods with
473
+ | Some ms -> ms.Methods |> Array.exists ( fun m -> m.Static.IsNone)
474
+ | _ -> false
475
+ | addedMs -> addedMs |> Array.exists ( fun m -> m.Static.IsNone || m.Static.Value = false )
476
+ let hasProperty =
477
+ if i.Properties.IsSome then true
478
+ else
479
+ JsonItems.getAddedItemsByInterfaceName ItemKind.Property flavor i.Name |> Array.isEmpty |> not
480
+ hasNonStaticMethod || hasProperty
481
+
482
+ let emitAddedConstructor () =
483
+ match JsonItems.getAddedItemsByInterfaceName ItemKind.Constructor flavor i.Name with
484
+ | [||] -> ()
485
+ | ctors ->
486
+ Pt.printl " prototype: %s ;" i.Name
487
+ ctors |> Array.iter ( fun ctor -> ctor.Signatures |> Array.iter ( Pt.printl " %s ;" ))
472
488
473
489
// For static types with non-static members, we put the non-static members into an
474
490
// interface, and put the static members into the object literal type of 'declare var'
475
491
// For static types with only static members, we put everything in the interface.
476
492
// Because in the two cases the interface contains different things, it might be easier to
477
493
// read to seperate them into two functions.
478
- let emitStaticInterfaceWithNonStaticMembers () =
494
+ let emitStaticInterfaceWithNonStaticMembers () =
479
495
Pt.resetIndent()
480
496
EmitInterfaceDeclaration i
481
497
Pt.increaseIndent()
@@ -492,6 +508,7 @@ let EmitStaticInterface flavor (i:Browser.Interface) =
492
508
Pt.increaseIndent()
493
509
EmitConstants i
494
510
EmitMembers flavor prefix EmitScope.StaticOnly i
511
+ emitAddedConstructor ()
495
512
Pt.decreaseIndent()
496
513
Pt.printl " }"
497
514
Pt.printl " "
@@ -506,7 +523,7 @@ let EmitStaticInterface flavor (i:Browser.Interface) =
506
523
EmitConstants i
507
524
EmitEventHandlers prefix i
508
525
EmitIndexers EmitScope.StaticOnly i
509
-
526
+ emitAddedConstructor ()
510
527
Pt.decreaseIndent()
511
528
Pt.printl " }"
512
529
Pt.printl " declare var %s : %s ;" i.Name i.Name
@@ -616,4 +633,4 @@ let EmitDomWeb () =
616
633
617
634
let EmitDomWorker () =
618
635
ignoreDOMTypes <- true
619
- EmitTheWholeThing Flavor.Worker GlobalVars.tsWorkerOutput
636
+ EmitTheWholeThing Flavor.Worker GlobalVars.tsWorkerOutput
0 commit comments