(
node: ts.Node,
outputState: JSXOutputState,
transformContext: ts.TransformationContext,
)
| 1271 | } |
| 1272 | |
| 1273 | private transformNode( |
| 1274 | node: ts.Node, |
| 1275 | outputState: JSXOutputState, |
| 1276 | transformContext: ts.TransformationContext, |
| 1277 | ): ts.Node { |
| 1278 | // this.logNode(node, outputState); |
| 1279 | |
| 1280 | outputState.nodeDepth++; |
| 1281 | |
| 1282 | try { |
| 1283 | if (ts.isJsxElement(node)) { |
| 1284 | const result = this.processJSXElement(node, outputState, transformContext); |
| 1285 | return this.mergeStatements(result, transformContext); |
| 1286 | } else if (ts.isJsxSelfClosingElement(node)) { |
| 1287 | const result = this.processSelfClosingJSXElement(node, outputState, transformContext); |
| 1288 | return this.mergeStatements(result, transformContext); |
| 1289 | } |
| 1290 | |
| 1291 | if (ts.isExpressionStatement(node)) { |
| 1292 | const result = this.transformNode(node.expression, outputState, transformContext); |
| 1293 | if (isExpressionNode(result)) { |
| 1294 | return transformContext.factory.updateExpressionStatement(node, result); |
| 1295 | } |
| 1296 | // We are not an expression anymore |
| 1297 | return result; |
| 1298 | } |
| 1299 | |
| 1300 | if (ts.isJsxExpression(node) && node.expression) { |
| 1301 | const result = this.transformNode(node.expression, outputState, transformContext); |
| 1302 | if (isExpressionNode(result)) { |
| 1303 | return transformContext.factory.updateJsxExpression(node, result); |
| 1304 | } |
| 1305 | return result; |
| 1306 | } |
| 1307 | |
| 1308 | if (ts.isParenthesizedExpression(node)) { |
| 1309 | const result = this.transformNode(node.expression, outputState, transformContext); |
| 1310 | if (isExpressionNode(result)) { |
| 1311 | return transformContext.factory.updateParenthesizedExpression(node, result); |
| 1312 | } |
| 1313 | |
| 1314 | return result; |
| 1315 | } |
| 1316 | |
| 1317 | if (ts.isBlock(node)) { |
| 1318 | const statements = node.statements.map((statement) => |
| 1319 | this.toStatement(this.transformNode(statement, outputState, transformContext), transformContext), |
| 1320 | ); |
| 1321 | |
| 1322 | const newStatements = this.flattenBlocks(node, node.statements, statements); |
| 1323 | return transformContext.factory.updateBlock(node, newStatements); |
| 1324 | } |
| 1325 | |
| 1326 | return ts.visitEachChild( |
| 1327 | node, |
| 1328 | (childNode) => this.transformNodeGeneric(node, childNode, outputState, transformContext), |
| 1329 | transformContext, |
| 1330 | ); |
no test coverage detected