MCPcopy Index your code
hub / github.com/nodejs/node / tryGetElementAccessExpressionName

Function tryGetElementAccessExpressionName

test/fixtures/snapshot/typescript.js:69372–69396  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

69370 type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
69371 }
69372 function tryGetElementAccessExpressionName(node) {
69373 if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
69374 return ts.escapeLeadingUnderscores(node.argumentExpression.text);
69375 }
69376 if (ts.isEntityNameExpression(node.argumentExpression)) {
69377 var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
69378 if (!symbol || !isConstVariable(symbol))
69379 return undefined;
69380 var declaration = symbol.valueDeclaration;
69381 if (declaration === undefined)
69382 return undefined;
69383 var type = tryGetTypeFromEffectiveTypeNode(declaration);
69384 if (type) {
69385 var name = tryGetNameFromType(type);
69386 if (name !== undefined) {
69387 return name;
69388 }
69389 }
69390 if (ts.hasOnlyExpressionInitializer(declaration)) {
69391 var initializer = ts.getEffectiveInitializer(declaration);
69392 return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
69393 }
69394 }
69395 return undefined;
69396 }
69397 function containsMatchingReference(source, target) {
69398 while (ts.isAccessExpression(source)) {
69399 source = source.expression;

Callers 1

getAccessedPropertyNameFunction · 0.85

Calls 5

resolveEntityNameFunction · 0.85
isConstVariableFunction · 0.85
tryGetNameFromTypeFunction · 0.85
getTypeOfExpressionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…