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

Method TypeParameterToStringEx

internal/checker/printer.go:458–476  ·  view source on GitHub ↗

TypeParameterToStringEx renders a type parameter declaration (e.g. "T extends Foo") with optional verbosity support.

(t *Type, enclosingDeclaration *ast.Node, vc *VerbosityContext)

Source from the content-addressed store, hash-verified

456
457// TypeParameterToStringEx renders a type parameter declaration (e.g. "T extends Foo") with optional verbosity support.
458func (c *Checker) TypeParameterToStringEx(t *Type, enclosingDeclaration *ast.Node, vc *VerbosityContext) string {
459 nodeBuilder, release := c.getNodeBuilder()
460 defer release()
461 oldVerbosity := nodeBuilder.verbosity
462 nodeBuilder.verbosity = vc
463 defer func() {
464 nodeBuilder.verbosity = oldVerbosity
465 }()
466 typeParamNode := nodeBuilder.TypeParameterToDeclaration(t, enclosingDeclaration, nodebuilder.FlagsIgnoreErrors, nodebuilder.InternalFlagsNone, nil)
467 if typeParamNode == nil {
468 return c.TypeToString(t)
469 }
470 p := createPrinterWithRemoveComments(nodeBuilder.EmitContext())
471 var sourceFile *ast.SourceFile
472 if enclosingDeclaration != nil {
473 sourceFile = ast.GetSourceFileOfNode(enclosingDeclaration)
474 }
475 return p.Emit(typeParamNode, sourceFile)
476}
477
478func (c *Checker) TypeToTypeNodeEx(t *Type, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, idToSymbol map[*ast.IdentifierNode]*ast.Symbol) *ast.TypeNode {
479 nodeBuilder := c.getNodeBuilderEx(idToSymbol)

Callers 1

typeParameterToStringFunction · 0.80

Calls 7

getNodeBuilderMethod · 0.95
TypeToStringMethod · 0.95
GetSourceFileOfNodeFunction · 0.92
EmitMethod · 0.65
EmitContextMethod · 0.45

Tested by

no test coverage detected