MCPcopy Index your code
hub / github.com/microsoft/typescript-go / emitPropertyAssignment

Method emitPropertyAssignment

internal/printer/printer.go:4511–4530  ·  view source on GitHub ↗

Property assignments

(node *ast.PropertyAssignment)

Source from the content-addressed store, hash-verified

4509//
4510
4511func (p *Printer) emitPropertyAssignment(node *ast.PropertyAssignment) {
4512 state := p.enterNode(node.AsNode())
4513 p.emitPropertyName(node.Name())
4514 p.writePunctuation(":")
4515 p.writeSpace()
4516 // This is to ensure that we emit comment in the following case:
4517 // For example:
4518 // obj = {
4519 // id: /*comment1*/ ()=>void
4520 // }
4521 // "comment1" is not considered to be leading comment for node.initializer
4522 // but rather a trailing comment on the previous node.
4523 initializer := node.Initializer
4524 if p.emitContext.EmitFlags(initializer)&EFNoLeadingComments == 0 {
4525 commentRange := p.emitContext.CommentRange(initializer)
4526 p.emitTrailingComments(commentRange.Pos(), commentSeparatorAfter)
4527 }
4528 p.emitExpression(initializer, ast.OperatorPrecedenceDisallowComma)
4529 p.exitNode(node.AsNode(), state)
4530}
4531
4532func (p *Printer) emitShorthandPropertyAssignment(node *ast.ShorthandPropertyAssignment) {
4533 state := p.enterNode(node.AsNode())

Callers 2

WriteMethod · 0.95

Calls 12

enterNodeMethod · 0.95
emitPropertyNameMethod · 0.95
writePunctuationMethod · 0.95
writeSpaceMethod · 0.95
emitTrailingCommentsMethod · 0.95
emitExpressionMethod · 0.95
exitNodeMethod · 0.95
EmitFlagsMethod · 0.80
CommentRangeMethod · 0.80
AsNodeMethod · 0.65
NameMethod · 0.65
PosMethod · 0.65

Tested by

no test coverage detected