MCPcopy Create free account
hub / github.com/Snapchat/Valdi / toExpression

Method toExpression

compiler/companion/src/JSXProcessor.ts:237–258  ·  view source on GitHub ↗
(node: ts.Node, transformContext: ts.TransformationContext)

Source from the content-addressed store, hash-verified

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])) {

Callers 6

outputSlotExpressionMethod · 0.95
outputElementInnerMethod · 0.95
outputJSXComponentMethod · 0.95
transformNodeGenericMethod · 0.95

Calls 3

toBlockMethod · 0.95
toStatementMethod · 0.95
isExpressionNodeFunction · 0.90

Tested by

no test coverage detected