diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 9e3dee9440586..52a1fa28eaf1a 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -1454,7 +1454,7 @@ const visitEachChildTable: VisitEachChildTable = { [SyntaxKind.JsxExpression]: function visitEachChildOfJsxExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateJsxExpression(node, - Debug.checkDefined(nodeVisitor(node.expression, visitor, isExpression))); + nodeVisitor(node.expression, visitor, isExpression)); }, // Clauses diff --git a/src/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index 89331f93c4242..b8c080a871ad8 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -669,5 +669,31 @@ const MyClass = class { }).outputText; }); + testBaseline("jsxExpression", () => { + function doNothing(context: ts.TransformationContext) { + const visitor = (node: ts.Node): ts.Node => { + return ts.visitEachChild(node, visitor, context); + }; + return (node: ts.SourceFile) => ts.visitNode(node, visitor, ts.isSourceFile); + } + + return ts.transpileModule(` +function test () { + return <> + {/* This comment breaks the transformer */} + +} +`, { + transformers: { + before: [doNothing], + }, + compilerOptions: { + jsx: ts.JsxEmit.React, + target: ScriptTarget.ES2015, + experimentalDecorators: true, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + }); }); diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.jsxExpression.js b/tests/baselines/reference/transformApi/transformsCorrectly.jsxExpression.js new file mode 100644 index 0000000000000..5d97a368af04d --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.jsxExpression.js @@ -0,0 +1,3 @@ +function test() { + return React.createElement(React.Fragment, null); +}