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

Method emitHelpers

internal/printer/printer.go:4604–4630  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

4602}
4603
4604func (p *Printer) emitHelpers(node *ast.Node) bool {
4605 helpersEmitted := false
4606 sourceFile := p.currentSourceFile
4607 shouldSkip := p.Options.NoEmitHelpers || (sourceFile != nil && p.emitContext.HasRecordedExternalHelpers(sourceFile))
4608 helpers := slices.Clone(p.emitContext.GetEmitHelpers(node))
4609 if len(helpers) > 0 {
4610 slices.SortStableFunc(helpers, compareEmitHelpers)
4611 for _, helper := range helpers {
4612 if !helper.Scoped {
4613 // Skip the helper if it can be skipped and the noEmitHelpers compiler
4614 // option is set, or if it can be imported and the importHelpers compiler
4615 // option is set.
4616 if shouldSkip {
4617 continue
4618 }
4619 }
4620 if helper.TextCallback != nil {
4621 p.writeLines(helper.TextCallback(p.makeFileLevelOptimisticUniqueName))
4622 } else {
4623 p.writeLines(helper.Text)
4624 }
4625 helpersEmitted = true
4626 }
4627 }
4628
4629 return helpersEmitted
4630}
4631
4632func (p *Printer) emitSourceFile(node *ast.SourceFile) {
4633 savedCurrentSourceFile := p.currentSourceFile

Callers 2

emitFunctionBodyMethod · 0.95
emitSourceFileMethod · 0.95

Calls 5

writeLinesMethod · 0.95
lenFunction · 0.85
GetEmitHelpersMethod · 0.80
CloneMethod · 0.65

Tested by

no test coverage detected