Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3837 #3844

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [All] Fixed Fable compiler hanging on some errors (#3842) (by @ncave)
* [JS/TS] Fixed DateTime.MinValue, DateTime.MaxValue (#3836) (by @ncave)
* [JS/TS] Fixed missing field using TypeScriptTaggedUnion (#3837) (by @ncave)

## 4.19.0 - 2024-06-10

Expand Down
5 changes: 3 additions & 2 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ type FsUnionCase(uci: FSharpUnionCase) =
| _ -> None
)

static member HasNamedFields(uci: FSharpUnionCase) =
not (uci.Fields.Count = 1 && uci.Fields[0].Name = "Item")
// static member HasNamedFields(uci: FSharpUnionCase) =
// not (uci.Fields.Count = 1 && uci.Fields[0].Name = "Item")
// true

interface Fable.UnionCase with
member _.Name = uci.Name
Expand Down
20 changes: 10 additions & 10 deletions src/Fable.Transforms/FSharp2Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let private transformNewUnion com ctx r fsType (unionCase: FSharpUnionCase) (arg

| TypeScriptTaggedUnion(_, _, tagName, rule) ->
match argExprs with
| [ argExpr ] when not (FsUnionCase.HasNamedFields unionCase) -> argExpr
// | [ argExpr ] when not (FsUnionCase.HasNamedFields unionCase) -> argExpr
| _ ->
let isCompiledValue, tagExpr =
match FsUnionCase.CompiledValue unionCase with
Expand Down Expand Up @@ -1176,16 +1176,16 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs

return Fable.Get(unionExpr, Fable.TupleIndex index, fieldType, r)
| TypeScriptTaggedUnion _ ->
if FsUnionCase.HasNamedFields unionCase then
let kind =
Fable.FieldInfo.Create(
FsField.FSharpFieldName field,
fieldType = makeType Map.empty field.FieldType
)
// if not (FsUnionCase.HasNamedFields unionCase) then
// return unionExpr
// else
let kind =
Fable.FieldInfo.Create(
FsField.FSharpFieldName field,
fieldType = makeType Map.empty field.FieldType
)

return Fable.Get(unionExpr, kind, fieldType, r)
else
return unionExpr
return Fable.Get(unionExpr, kind, fieldType, r)
| StringEnum _ ->
return
"StringEnum types cannot have fields"
Expand Down
12 changes: 6 additions & 6 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,12 @@ module Annotation =
AbstractMember.abstractProperty (prop, tagType, isComputed = isComputed)

match uci.UnionCaseFields with
| [ field ] when field.Name = "Item" ->
IntersectionTypeAnnotation
[|
field.FieldType |> resolveInlineType genArgs |> makeFieldAnnotation com ctx
ObjectTypeAnnotation [| tagMember |]
|]
// | [ field ] when field.Name = "Item" ->
// IntersectionTypeAnnotation
// [|
// field.FieldType |> resolveInlineType genArgs |> makeFieldAnnotation com ctx
// ObjectTypeAnnotation [| tagMember |]
// |]
| fields ->
let names, types =
fields |> List.map (fun fi -> fi.Name, fi.FieldType) |> List.unzip
Expand Down
Loading