Remove extra checkDefined in visitEachChildOfJsxExpression (#52482)

This commit is contained in:
Jake Bailey 2023-01-29 17:07:58 -08:00 committed by GitHub
parent ac24daad6d
commit 39a9ac84fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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;
});
});

View File

@ -0,0 +1,3 @@
function test() {
return React.createElement(React.Fragment, null);
}