How to create ComplexType representing anonymous structure with optional fields?
NQNStudios opened this issue · comments
In a build macro, I want to create a ComplexType TAnonymous([fields...])
in which some of the fields are optional. But haxe.macro.Field
doesn't have an opt
parameter, and when I put TOptional(type)
as a field object's type, the compiler says " Optional type not allowed here"
I also tried prefixing the name of a Field object with "?", to emulate the syntax
{?field:Type}
which works in normal haxe type definitions.
When I did this, referencing my anonymous type's fields would cause a compiler error "{?field: Type } has no field field (Suggestion: ?field)" which is weird.
I figured out that adding :optional
to a Field's meta
achieves the desired result.