(node: ts.Node, transformContext: ts.TransformationContext)
| 235 | } |
| 236 | |
| 237 | private toExpression(node: ts.Node, transformContext: ts.TransformationContext): ts.Expression { |
| 238 | if (isExpressionNode(node)) { |
| 239 | return node; |
| 240 | } |
| 241 | |
| 242 | if (ts.isExpressionStatement(node)) { |
| 243 | return node.expression; |
| 244 | } |
| 245 | |
| 246 | // Convert to an immediately called lambda |
| 247 | |
| 248 | const arrowFunction = transformContext.factory.createArrowFunction( |
| 249 | undefined, |
| 250 | undefined, |
| 251 | [], |
| 252 | undefined, |
| 253 | undefined, |
| 254 | this.toBlock([this.toStatement(node, transformContext)], transformContext), |
| 255 | ); |
| 256 | |
| 257 | return transformContext.factory.createCallExpression(arrowFunction, [], []); |
| 258 | } |
| 259 | |
| 260 | private toBlock(statements: ts.Statement[], transformContext: ts.TransformationContext): ts.Block { |
| 261 | if (statements.length === 1 && ts.isBlock(statements[0])) { |
no test coverage detected