@@ -717,12 +717,11 @@ module Emit =
717
717
// Name of an interface / enum / dict. Just return itself
718
718
if allInterfacesMap.ContainsKey objDomType ||
719
719
allCallbackFuncs.ContainsKey objDomType ||
720
- allDictionariesMap.ContainsKey objDomType then
720
+ allDictionariesMap.ContainsKey objDomType ||
721
+ allEnumsMap.ContainsKey objDomType then
721
722
objDomType
722
723
// Name of a type alias. Just return itself
723
724
elif typeDefSet.Contains objDomType then objDomType
724
- // Enum types are all treated as string
725
- elif allEnumsMap.ContainsKey objDomType then " string"
726
725
// Union types
727
726
elif objDomType.Contains( " or " ) then
728
727
let allTypes = objDomType.Trim( '(' , ')' ) .Split([| " or " |], StringSplitOptions.None)
@@ -883,7 +882,8 @@ module Emit =
883
882
GetCallbackFuncsByFlavor flavor |> Array.iter emitCallBackFunction
884
883
885
884
let EmitEnums () =
886
- let emitEnum ( e : Browser.Enum ) = Pt.Printl " declare var %s : string;" e.Name
885
+ let emitEnum ( e : Browser.Enum ) =
886
+ Pt.Printl " type %s = %s ;" e.Name ( String.Join( " | " , e.Values |> Array.map ( fun value -> " \" " + value + " \" " )))
887
887
browser.Enums |> Array.iter emitEnum
888
888
889
889
let EmitEventHandlerThis flavor ( prefix : string ) ( i : Browser.Interface ) =
@@ -1484,6 +1484,7 @@ module Emit =
1484
1484
| _ -> ()
1485
1485
1486
1486
EmitTypeDefs flavor
1487
+ EmitEnums()
1487
1488
1488
1489
fprintf target " %s " ( Pt.GetResult())
1489
1490
target.Flush()
0 commit comments