Emit a field under the defined name, with value being the enum constructor name. For nicer consumption in native js code (without relying on the ugly _hx_index field).
Example:
-D genes.enum_discriminator=$kind
Would emit haxe.ds.Option.None as {_hx_index:0, $kind:"None"} and haxe.ds.Option.Some(42) as {_hx_index:1, $kind:"Some", value:42} (not exact but you get the idea)
So in native JS/TS code one can consume the value with:
switch (option.$kind) {
case "None":
case "Some": option.value // type-safe access
}
Emit a field under the defined name, with value being the enum constructor name. For nicer consumption in native js code (without relying on the ugly _hx_index field).
Example:
-D genes.enum_discriminator=$kind
Would emit
haxe.ds.Option.None
as{_hx_index:0, $kind:"None"}
andhaxe.ds.Option.Some(42)
as{_hx_index:1, $kind:"Some", value:42}
(not exact but you get the idea)So in native JS/TS code one can consume the value with: