@@ -684,7 +684,6 @@ module Emit =
684
684
| " DOMString" -> " string"
685
685
| " DOMTimeStamp" -> " number"
686
686
| " EndOfStreamError" -> " number"
687
- | " EventListener" -> " EventListenerOrEventListenerObject"
688
687
| " double" | " float" -> " number"
689
688
| " object" -> " any"
690
689
| " ReadyState" -> " string"
@@ -838,11 +837,14 @@ module Emit =
838
837
( if p.Variadic then " []" else " " )
839
838
String.Join( " , " , ( List.map paramToString ps))
840
839
841
- let EmitCallBackInterface ( i : Browser.Interface ) =
842
- Pt.Printl " interface %s {" i.Name
843
- Pt.PrintWithAddedIndent " (evt: Event): void;"
844
- Pt.Printl " }"
845
- Pt.Printl " "
840
+ let EmitCallBackInterface flavor ( i : Browser.Interface ) =
841
+ if ShouldKeep flavor i then
842
+ let m = i.Methods.Value.Methods.[ 0 ]
843
+ let overload = ( GetOverloads ( Function.Method m) false ).[ 0 ]
844
+ let paramsString = ParamsToString overload.ParamCombinations
845
+ let returnType = DomTypeToTsType m.Type
846
+ Pt.Printl " type %s = (%s ) => %s | { %s (%s ): %s ; };" i.Name paramsString returnType m.Name.Value paramsString returnType
847
+ Pt.Printl " "
846
848
847
849
let EmitCallBackFunctions flavor =
848
850
let emitCallbackFunctionsFromJson ( cb : InputJson.InputJsonType.Root ) =
@@ -1064,7 +1066,7 @@ module Emit =
1064
1066
1065
1067
let emitStringEventHandler ( addOrRemove : string ) =
1066
1068
Pt.Printl
1067
- " %s%s EventListener(type: string, listener: EventListenerOrEventListenerObject , options?: boolean | %s ): void;"
1069
+ " %s%s EventListener(type: string, listener: EventListener , options?: boolean | %s ): void;"
1068
1070
fPrefix addOrRemove ( getOptionsType addOrRemove)
1069
1071
1070
1072
let tryEmitTypedEventHandlerForInterface ( addOrRemove : string ) =
@@ -1484,15 +1486,12 @@ module Emit =
1484
1486
Pt.Printl " "
1485
1487
1486
1488
EmitDictionaries flavor
1487
- browser.CallbackInterfaces.Interfaces |> Array.iter EmitCallBackInterface
1489
+ browser.CallbackInterfaces.Interfaces |> Array.iter ( EmitCallBackInterface flavor )
1488
1490
EmitNonCallbackInterfaces flavor
1489
1491
1490
1492
// Add missed interface definition from the spec
1491
1493
InputJson.getAddedItems InputJson.Interface flavor |> Array.iter EmitAddedInterface
1492
1494
1493
- Pt.Printl " declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;"
1494
- Pt.Printl " "
1495
-
1496
1495
EmitCallBackFunctions flavor
1497
1496
1498
1497
if flavor <> Worker then
0 commit comments