Skip to content

Commit d2e8dd3

Browse files
committedAug 27, 2018
Compilation warning on missing props: handle functions too
1 parent c9c345a commit d2e8dd3

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed
 

‎src/lib/react/ReactMacro.hx

+16-7
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,23 @@ class ReactMacro
190190
var neededAttrs = [];
191191

192192
try {
193-
var tprops = Context.storeTypedExpr(Context.typeExpr(macro @:pos(type.pos) {
194-
function get<T>(c:Class<T>):T return null;
195-
@:privateAccess get($type).props;
196-
}));
193+
switch (Context.typeof(type)) {
194+
case TType(_, _):
195+
var tprops = Context.storeTypedExpr(Context.typeExpr(macro @:pos(type.pos) {
196+
function get<T>(c:Class<T>):T return null;
197+
@:privateAccess get($type).props;
198+
}));
197199

198-
switch (Context.typeof(tprops))
199-
{
200-
case TType(_.get() => _.type => TAnonymous(_.get().fields => fields), _):
200+
switch (Context.typeof(tprops)) {
201+
case TType(_.get() => _.type => TAnonymous(_.get().fields => fields), _):
202+
for (f in fields)
203+
if (!f.meta.has(':optional'))
204+
neededAttrs.push(f.name);
205+
206+
default:
207+
}
208+
209+
case TFun([{t: TType(_.get() => _.type => TAnonymous(_.get().fields => fields), _)}], _):
201210
for (f in fields)
202211
if (!f.meta.has(':optional'))
203212
neededAttrs.push(f.name);

0 commit comments

Comments
 (0)