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

Function GetDeclarationName

internal/ast/ast.go:2957–2972  ·  view source on GitHub ↗
(declaration *Node)

Source from the content-addressed store, hash-verified

2955}
2956
2957func GetDeclarationName(declaration *Node) string {
2958 name := GetNonAssignedNameOfDeclaration(declaration)
2959 if name != nil {
2960 if IsComputedPropertyName(name) {
2961 if IsStringOrNumericLiteralLike(name.Expression()) {
2962 return name.Expression().Text()
2963 }
2964 if IsPropertyAccessExpression(name.Expression()) {
2965 return name.Expression().Name().Text()
2966 }
2967 } else if IsPropertyName(name) {
2968 return name.Text()
2969 }
2970 }
2971 return ""
2972}
2973
2974type SourceFileLike interface {
2975 Text() string

Calls 8

IsComputedPropertyNameFunction · 0.85
IsPropertyNameFunction · 0.85
ExpressionMethod · 0.80
TextMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected