You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IsUnion returns false for typeof<Option<int>> #2110
This issue is addressed by draft PR #4529: Fix FSharpOption not recognized as union type in F# reflection.
The root cause is that option_type() in fable-library-ts/Reflection.ts and fable-library-py/fable_library/reflection.py creates a TypeInfo without a cases property, so:
FSharpValue.GetUnionFields and MakeUnion also fail for option types
PR #4529 rewrites option_type() to expose None (tag 0) and Some (tag 1) as union cases, and adds option-aware handling in getUnionFields/makeUnion to deal with Fable's erased runtime representation (None = undefined/null, Some(x) = x directly).
Activity
alfonsogarciacaro commentedon Jul 1, 2020
Yes, in Fable option is a special type and is not like other unions. Although I guess we could fix it in the reflection info.
Fable/src/fable-library/Reflection.ts
Lines 111 to 113 in 7d02d3e
Do you have an example of a scenario that's being blocked by this?
kerams commentedon Jul 1, 2020
https://github.com/Zaid-Ajaj/Fable.Remoting/pull/158/files#diff-5bdc4da2122faa430fe9e2f88bdb24e6R425
Not really a blocker since one can always specifically typecheck for Option.
github-actions commentedon Apr 17, 2026
🤖 This is an automated response from Repo Assist.
This issue is addressed by draft PR #4529: Fix FSharpOption not recognized as union type in F# reflection.
The root cause is that
option_type()infable-library-ts/Reflection.tsandfable-library-py/fable_library/reflection.pycreates aTypeInfowithout acasesproperty, so:FSharpType.IsUnion(typeof<option<int>>)returnsfalseFSharpType.GetUnionCases(typeof<option<int>>)throwsFSharpValue.GetUnionFieldsandMakeUnionalso fail for option typesPR #4529 rewrites
option_type()to exposeNone(tag 0) andSome(tag 1) as union cases, and adds option-aware handling ingetUnionFields/makeUnionto deal with Fable's erased runtime representation (None = undefined/null, Some(x) = x directly).MangelMaxime commentedon May 28, 2026
Fixed in #4529