diff --git a/src/Fable.Cli/CHANGELOG.md b/src/Fable.Cli/CHANGELOG.md index 425cad124..a9925b5c2 100644 --- a/src/Fable.Cli/CHANGELOG.md +++ b/src/Fable.Cli/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* [JS/TS] Fix #4025: No reflection info for pojos (by @alfonsogarciacaro) * [JS/TS] Fix #4049: decimal/bigint to integer conversion checks (by @ncave) ## 5.0.0-alpha.10 - 2025-02-16 diff --git a/src/Fable.Compiler/CHANGELOG.md b/src/Fable.Compiler/CHANGELOG.md index 37b07dcd6..cde9066de 100644 --- a/src/Fable.Compiler/CHANGELOG.md +++ b/src/Fable.Compiler/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* [JS/TS] Fix #4025: No reflection info for pojos (by @alfonsogarciacaro) * [JS/TS] Fix #4049: decimal/bigint to integer conversion checks (by @ncave) ## 5.0.0-alpha.10 - 2025-02-16 diff --git a/src/Fable.Transforms/Fable2Babel.fs b/src/Fable.Transforms/Fable2Babel.fs index b67c31271..d2e51ddee 100644 --- a/src/Fable.Transforms/Fable2Babel.fs +++ b/src/Fable.Transforms/Fable2Babel.fs @@ -396,7 +396,10 @@ module Reflection = |> List.toArray match com.GetEntity(entRef) with - | Patterns.Try (Util.tryFindAnyEntAttribute [ Atts.stringEnum; Atts.erase; Atts.tsTaggedUnion ]) (att, _) as ent -> + | Patterns.Try (Util.tryFindAnyEntAttribute [ Atts.stringEnum + Atts.erase + Atts.tsTaggedUnion + Atts.pojoDefinedByConsArgs ]) (att, _) as ent -> match att with | Atts.stringEnum -> primitiveTypeInfo "string" | Atts.erase -> diff --git a/tests/Js/Main/JsInteropTests.fs b/tests/Js/Main/JsInteropTests.fs index 2412db10a..37b30b954 100644 --- a/tests/Js/Main/JsInteropTests.fs +++ b/tests/Js/Main/JsInteropTests.fs @@ -317,25 +317,27 @@ module TaggedUnion = #if FABLE_COMPILER module PojoDefinedByConsArgs = - open Fable.Core.JS - - [] + [] type Person( name : string ) = member val name = name - [] + [] type User( id: int, name: string, ?age: int ) = inherit Person(name) member val id = id member val age = age with get, set member val name = name - [] + type Team = { + Leader: User + } + + [] type BaseBag<'T>() = new ( bag : 'T) = BaseBag() member val bag: 'T = jsNative - [] + [] type UserBag<'ExtraData> private () = inherit BaseBag() new ( bag : int, data: 'ExtraData, ?userId : int) = UserBag() @@ -382,6 +384,17 @@ module PojoDefinedByConsArgs = user.age |> equal None user.age <- Some 42 user.age |> equal (Some 42) + + testCase "Declared types can reference Pojo class" <| fun _ -> + let expected = [|"Fable.Tests.JsInterop.PojoDefinedByConsArgs.User"|] + + FSharp.Reflection.FSharpType.GetRecordFields typeof + |> Array.map (fun f -> f.PropertyType.FullName) + |> equal expected + + FSharp.Reflection.FSharpType.GetRecordFields typeof<{| Leader: User |}> + |> Array.map (fun f -> f.PropertyType.FullName) + |> equal expected ] #endif