(node *ast.ExpressionStatement)
| 3400 | } |
| 3401 | |
| 3402 | func (p *Printer) emitExpressionStatement(node *ast.ExpressionStatement) { |
| 3403 | state := p.enterNode(node.AsNode()) |
| 3404 | |
| 3405 | if p.currentSourceFile != nil && p.currentSourceFile.ScriptKind == core.ScriptKindJSON { |
| 3406 | // !!! In strada, this was handled by an undefined parenthesizerRule, so this is a hack. |
| 3407 | p.emitExpression(node.Expression, ast.OperatorPrecedenceComma) |
| 3408 | } else if isImmediatelyInvokedFunctionExpressionOrArrowFunction(node.Expression) { |
| 3409 | // For IIFEs, parenthesize just the callee (not the whole call), matching TypeScript's |
| 3410 | // parenthesizeExpressionOfExpressionStatement which wraps the function/arrow in parens: |
| 3411 | // (function() { })() -- not (function() { }()) |
| 3412 | p.emitIIFEWithParenthesizedCallee(node.Expression) |
| 3413 | } else { |
| 3414 | switch ast.GetLeftmostExpression(node.Expression, false /*stopAtCallExpression*/).Kind { |
| 3415 | case ast.KindFunctionExpression, ast.KindObjectLiteralExpression: |
| 3416 | p.emitExpression(node.Expression, ast.OperatorPrecedenceParentheses) |
| 3417 | default: |
| 3418 | p.emitExpression(node.Expression, ast.OperatorPrecedenceComma) |
| 3419 | } |
| 3420 | } |
| 3421 | |
| 3422 | // Emit semicolon in non json files |
| 3423 | // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) |
| 3424 | if p.currentSourceFile == nil || |
| 3425 | p.currentSourceFile.ScriptKind != core.ScriptKindJSON || |
| 3426 | ast.NodeIsSynthesized(node.Expression) { |
| 3427 | p.writeTrailingSemicolon() |
| 3428 | } |
| 3429 | |
| 3430 | p.exitNode(node.AsNode(), state) |
| 3431 | } |
| 3432 | |
| 3433 | // emitIIFEWithParenthesizedCallee emits a call expression that is an IIFE, |
| 3434 | // wrapping just the callee in parens rather than the entire call expression. |
no test coverage detected