COMMUNITY

How to convert haxe.macro.Type to expr?

how to convert haxe.marco.Type to expr?



  var tt=ComplexTypeTools.toType(t);//this is type of Int or Float

 var objx:ObjectField={field: "ct",expr:macro {type:Int }};//work.

 var objx:ObjectField={field: "ct",expr:macro {type:${tt} }};//error .Null<haxe.macro.Type> should be haxe.macro.Expr

edit

use ComplexTypeTools.toString() instead of ComplexTypeTools.toType()

var objx:ObjectField={field: "ct",expr:macro {"default":$v{dd},type:$i{ss} }};

fixed.

You have a ComplexType there with t, you should be able to do var objx:ObjectField={field: "ct",expr:macro {type: $t }};