Skip to content

Commit 39a9ac8

Browse files
authored
Remove extra checkDefined in visitEachChildOfJsxExpression (#52482)
1 parent ac24daa commit 39a9ac8

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/compiler/visitorPublic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ const visitEachChildTable: VisitEachChildTable = {
14541454

14551455
[SyntaxKind.JsxExpression]: function visitEachChildOfJsxExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
14561456
return context.factory.updateJsxExpression(node,
1457-
Debug.checkDefined(nodeVisitor(node.expression, visitor, isExpression)));
1457+
nodeVisitor(node.expression, visitor, isExpression));
14581458
},
14591459

14601460
// Clauses

src/testRunner/unittests/transform.ts

+26
Original file line numberDiff line numberDiff line change
@@ -669,5 +669,31 @@ const MyClass = class {
669669
}).outputText;
670670
});
671671

672+
testBaseline("jsxExpression", () => {
673+
function doNothing(context: ts.TransformationContext) {
674+
const visitor = (node: ts.Node): ts.Node => {
675+
return ts.visitEachChild(node, visitor, context);
676+
};
677+
return (node: ts.SourceFile) => ts.visitNode(node, visitor, ts.isSourceFile);
678+
}
679+
680+
return ts.transpileModule(`
681+
function test () {
682+
return <>
683+
{/* This comment breaks the transformer */}
684+
</>
685+
}
686+
`, {
687+
transformers: {
688+
before: [doNothing],
689+
},
690+
compilerOptions: {
691+
jsx: ts.JsxEmit.React,
692+
target: ScriptTarget.ES2015,
693+
experimentalDecorators: true,
694+
newLine: NewLineKind.CarriageReturnLineFeed,
695+
}
696+
}).outputText;
697+
});
672698
});
673699

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function test() {
2+
return React.createElement(React.Fragment, null);
3+
}

0 commit comments

Comments
 (0)