Skip to content

Commit

Permalink
Do not generated duplicate types for union with enum type
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Jan 31, 2024
1 parent ba4db66 commit 05c11a1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Targets/ReScript/Writer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,15 @@ and emitUnion (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: Context)
| LInt i -> Choice1Of2 {| name = Choice2Of2 i; value = None; attr = attr |}
| LFloat _ -> Choice2Of2 (ty |? Type.float)
| LBool _ -> Choice2Of2 (ty |? Type.boolean)
let cases = [
for c in cases do
match c with
| Choice1Of2 (_, _, ty) ->
let ty = emitTypeImpl (EmitTypeFlags.noExternal flags) overrideFunc ctx ty
yield Choice2Of2 ty
| Choice2Of2 l -> yield handleLiteral l None None
]
let cases =
List.distinct [
for c in cases do
match c with
| Choice1Of2 (_, _, ty) ->
let ty = emitTypeImpl (EmitTypeFlags.noExternal flags) overrideFunc ctx ty
yield Choice2Of2 ty
| Choice2Of2 l -> yield handleLiteral l None None
]
let cases, rest = List.splitChoice2 cases
[
if List.isEmpty cases |> not then
Expand Down

0 comments on commit 05c11a1

Please sign in to comment.