Skip to content

Commit

Permalink
Fix jsx macro error
Browse files Browse the repository at this point in the history
  • Loading branch information
terurou committed Nov 17, 2023
1 parent f174994 commit 7cfb36d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/react/ReactMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ class ReactMacro
}

// Support "import as"
function deepFollow(t:Type) return TypeTools.map(Context.follow(t), deepFollow);
function deepFollow(t:Type) {
if (t == null) return null;
return TypeTools.map(Context.follow(t), deepFollow);
}

var t = deepFollow(Context.typeof(macro {
var __pseudo = $target;
Expand Down
13 changes: 13 additions & 0 deletions test/src/ReactMacroTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class CompBasic extends ReactComponent {}
@:ignoreEmptyRender
class CompBasicProps extends ReactComponentOfProps<{a:Int}> {}

@:ignoreEmptyRender
class CompRenderFunctionProps extends ReactComponentOfProps<{?render:()->ReactElement}> {}

typedef RenderProps = {
@:optional var children:Int->ReactFragment;
}
Expand Down Expand Up @@ -409,6 +412,16 @@ class ReactMacroTest
}
}

@Test
public function render_function_props() {
function fn() return jsx('<></>');
var e = jsx('<CompRenderFunctionProps render=${fn}/>');
assertHasProps(
e.props,
['render'], [fn]
);
}

@Test
public function DOM_with_children_should_be_array()
{
Expand Down

0 comments on commit 7cfb36d

Please sign in to comment.