(
parent: ts.Node,
node: ts.Node,
outputState: JSXOutputState,
transformContext: ts.TransformationContext,
)
| 1336 | // A version of transformNode which which will ensure that we transform statements into expressions |
| 1337 | // if our node was an expression |
| 1338 | private transformNodeGeneric( |
| 1339 | parent: ts.Node, |
| 1340 | node: ts.Node, |
| 1341 | outputState: JSXOutputState, |
| 1342 | transformContext: ts.TransformationContext, |
| 1343 | ): ts.Node { |
| 1344 | const result = this.transformNode(node, outputState, transformContext); |
| 1345 | |
| 1346 | if (isExpressionNode(node) && !isExpressionNode(result)) { |
| 1347 | if (ts.isArrowFunction(parent) && parent.body === node) { |
| 1348 | // Special case for arrow functions, we don't need to convert them to expression since |
| 1349 | // the body can be a statement |
| 1350 | return result; |
| 1351 | } |
| 1352 | |
| 1353 | // We were an expression but we are not anymore, convert to an expression |
| 1354 | return this.toExpression(result, transformContext); |
| 1355 | } |
| 1356 | |
| 1357 | return result; |
| 1358 | } |
| 1359 | |
| 1360 | private onError(node: ts.Node, message: string): never { |
| 1361 | const { line, character } = node.getSourceFile().getLineAndCharacterOfPosition(node.getStart()); |
no test coverage detected