Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
fix: support for multiple jsx children inside map()
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Oct 7, 2023
1 parent 5767d50 commit 5ee4cef
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,21 @@ function diagnoseExpression(

// Anything other than a identifier should be
if (!ts.isIdentifier(node)) {
let jsx;

// Finds a JSX element
ts.forEachChild(node, function loopSourceNodes(child) {
if (isJsx(ts, child)) {
jsx = child;
return;
}

ts.forEachChild(child, loopSourceNodes);
});
let tags = node.getChildren().filter((c) => isJsx(ts, c));

// If root JSX element found inside array, diagnose it,
// otherwise let the diagnostic pass
if (jsx) {
diagnoseJsxElement(ts, jsx, typeChecker, diagnostics);
if (tags.length) {
for (const tag of tags) {
diagnoseJsxElement(
ts,
tag as JsxElement | ts.JsxFragment,
typeChecker,
diagnostics
);
}

return;
}
}

Expand Down

0 comments on commit 5ee4cef

Please sign in to comment.