MCPcopy Create free account
hub / github.com/microsoft/typescript-go / emitConciseBody

Method emitConciseBody

internal/printer/printer.go:2652–2668  ·  view source on GitHub ↗
(node *ast.BlockOrExpression)

Source from the content-addressed store, hash-verified

2650}
2651
2652func (p *Printer) emitConciseBody(node *ast.BlockOrExpression) {
2653 switch {
2654 case ast.IsBlock(node):
2655 p.emitFunctionBody(node.AsBlock())
2656 case ast.IsObjectLiteralExpression(ast.GetLeftmostExpression(node, false /*stopAtCallExpressions*/)):
2657 // Wrap in ParenthesizedExpression to ensure parens are emitted after any leading
2658 // PartiallyEmittedExpression comments, matching TypeScript's factory-time wrapping
2659 // via parenthesizeConciseBodyOfArrowFunction.
2660 paren := p.emitContext.Factory.NewParenthesizedExpression(node)
2661 paren.Loc = node.Loc
2662 p.emitExpression(paren, ast.OperatorPrecedenceLowest)
2663 case ast.IsExpression(node):
2664 p.emitExpression(node, ast.OperatorPrecedenceYield)
2665 default:
2666 panic(fmt.Sprintf("unexpected ConciseBody: %v", node.Kind))
2667 }
2668}
2669
2670func (p *Printer) emitArrowFunction(node *ast.ArrowFunction) {
2671 state := p.enterNode(node.AsNode())

Callers 1

emitArrowFunctionMethod · 0.95

Calls 9

emitFunctionBodyMethod · 0.95
emitExpressionMethod · 0.95
IsBlockFunction · 0.92
GetLeftmostExpressionFunction · 0.92
IsExpressionFunction · 0.92
panicFunction · 0.85
AsBlockMethod · 0.80

Tested by

no test coverage detected