@@ -115,20 +115,24 @@ class ReactMacro
115
115
};
116
116
}
117
117
118
- static function typeChecker (type : Expr , nodePos : Position , isHtml : Bool )
118
+ static function typeChecker (type : Expr , nodePos : Position , isHtml : Bool ): StringAt -> Expr -> Expr
119
119
{
120
- function propsFor (placeholder : Expr ): StringAt -> Expr -> Void
120
+ function propsFor (placeholder : Expr ): StringAt -> Expr -> Expr
121
121
{
122
122
placeholder = Context .storeTypedExpr (Context .typeExpr (placeholder ));
123
123
124
124
return function (name : StringAt , value : Expr ) {
125
125
var field = name .value ;
126
126
var target = macro @:pos (name .pos ) $placeholder .$field ;
127
127
128
- Context .typeof (macro @:pos (value .pos ) {
128
+ var t = Context .typeof (macro @:pos (value .pos ) {
129
129
var __pseudo = $target ;
130
130
__pseudo = $value ;
131
131
});
132
+
133
+ var ct = haxe.macro. TypeTools .toComplexType (t );
134
+ if (ct == null ) return value ;
135
+ return macro @:pos (value .pos ) ($value : $ct );
132
136
}
133
137
}
134
138
@@ -149,12 +153,15 @@ class ReactMacro
149
153
}
150
154
151
155
return isHtml
152
- ? function (_ , _ ) {}
156
+ ? function (_ , e : Expr ) return e
153
157
: switch (t ) {
154
158
case TFun (args , _ ):
155
159
switch (args ) {
156
160
case []:
157
- function (_ , e : Expr ) e .reject (' no props allowed here' );
161
+ function (_ , e : Expr ) {
162
+ e .reject (' no props allowed here' );
163
+ return e ;
164
+ }
158
165
159
166
case [v ]:
160
167
propsFor (macro @:pos (type .pos ) {
@@ -168,7 +175,7 @@ class ReactMacro
168
175
}
169
176
170
177
case TInst (_ .toString () => " String" , []):
171
- function (_ , _ ) {} ;
178
+ function (_ , e : Expr ) return e ;
172
179
173
180
default :
174
181
propsFor (macro @:pos (type .pos ) {
@@ -204,8 +211,10 @@ class ReactMacro
204
211
205
212
function add (name : StringAt , e : Expr )
206
213
{
207
- checkProp (name , e );
208
- attrs .push ({ field : name .value , expr : e });
214
+ attrs .push ({
215
+ field : name .value ,
216
+ expr : checkProp (name , e )
217
+ });
209
218
}
210
219
211
220
for (attr in n .attributes )
0 commit comments