-
Notifications
You must be signed in to change notification settings - Fork 315
Description
With the code below,
type SubType<'T> =
{
SubValue: 'T
}
[<Erase>]
type TypeA<'T> = TypeA of (unit -> SubType<'T>)
type Updates =
{
Func : TypeA<unit>
}Fable generates this error:
error FABLE: Cannot get type info of generic parameter T. Fable erases generics at runtime, try inlining the functions so generics can be resolved at compile time.
This is because, here Func : TypeA<unit> has a concrete type giving.
However, for a library I am working on I kind of need this type of code supported.
A workaround, is to enable --noReflection flag in Fable but it means not reflection can happen anywhere, so perhaps it could be nice to introduce a [<NoReflection>] attribute to disable it only for specific types.
Another workaround is to use an anonymous record:
type Updates =
{|
VarView : TypeA<unit>
|}I will see if I can rewrite my library to use the anonymous record, as it would be better to not introduce an attribute for a really specific usage.