@@ -339,6 +339,17 @@ module TaggedUnion =
339339 | [<CompiledValue( Kind.Bar) >] Bar of Bar < Kind >
340340 | [<CompiledValue( Kind.Baz) >] Baz of Baz < Kind >
341341
342+
343+ [<RequireQualifiedAccess>]
344+ [<TypeScriptTaggedUnion( " type" ) >]
345+ type SimpleFoo =
346+ | Bar of baz : int
347+
348+ [<RequireQualifiedAccess>]
349+ [<TypeScriptTaggedUnion( " type" ) >]
350+ type FooGeneric < 'a > =
351+ | Bar of baz : 'a
352+
342353#if FABLE_ COMPILER
343354module PojoDefinedByConsArgs =
344355 [<JS.Pojo; AllowNullLiteral>]
@@ -960,6 +971,28 @@ let tests =
960971 TaggedUnion.EnumTagged.Foo !!{| kind = TaggedUnion.Kind.Foo; foo = " hello" |} |> describe |> equal " foo: hello"
961972 TaggedUnion.EnumTagged.Bar !!{| kind = TaggedUnion.Kind.Bar; bar = 42 |} |> describe |> equal " bar: 42"
962973 TaggedUnion.EnumTagged.Baz !!{| kind = TaggedUnion.Kind.Baz; baz = false |} |> describe |> equal " baz: false"
974+
975+ // Fix https://github.com/fable-compiler/Fable/issues/4378
976+ testCase " TypeScriptTaggedUnion produce the correct return type for a function" <| fun () ->
977+ let getFoo ( baz : int ) =
978+ ( TaggedUnion.SimpleFoo.Bar baz)
979+
980+ let foo = getFoo 10
981+
982+ equal ( TaggedUnion.SimpleFoo.Bar 10 ) foo
983+
984+ testCase " TypeScriptTaggedUnion produce the correct type for a value" <| fun () ->
985+ let foo1 = TaggedUnion.SimpleFoo.Bar 10
986+
987+ equal ( TaggedUnion.SimpleFoo.Bar 10 ) foo1
988+
989+ testCase " TypeScriptTaggedUnion produce the type even with generic type parameters" <| fun () ->
990+ let getFooGeneric ( baz : 'a ) : TaggedUnion.FooGeneric < 'a > =
991+ ( TaggedUnion.FooGeneric.Bar baz)
992+
993+ let fooGeneric = getFooGeneric 10
994+
995+ equal ( TaggedUnion.FooGeneric.Bar 10 ) fooGeneric
963996#endif
964997
965998 testCase " Pattern matching with StringEnum works" <| fun () ->
0 commit comments