Skip to content

Commit

Permalink
fix: don't generate U1 if an union is resolved as a single possible v…
Browse files Browse the repository at this point in the history
…alue

[converter]
  • Loading branch information
MangelMaxime committed May 7, 2024
1 parent 78fc0ae commit dcd5968
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Glutinum.Converter/Transform.fs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ let rec private transformType

if isOptional && others.Length = 1 then
FSharpType.Option(transformType context others.Head)
// Don't wrap in a U1 if there is only one case
else if others.Length = 1 then
transformType context others.Head
else
{
Attributes = []
Expand Down
1 change: 1 addition & 0 deletions tests/specs/references/unionType/singleUnionResolved.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type ColorInfo = number | false;
12 changes: 12 additions & 0 deletions tests/specs/references/unionType/singleUnionResolved.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module rec Glutinum

open Fable.Core
open Fable.Core.JsInterop
open System

type ColorInfo =
float

(***)
#r "nuget: Fable.Core"
(***)

0 comments on commit dcd5968

Please sign in to comment.