@@ -43041,7 +43041,7 @@ namespace ts {
43041
43041
// declaration, we need to start resolution at the declaration's container.
43042
43042
// Otherwise, we could incorrectly resolve the export container as the
43043
43043
// declaration if it contains an exported member with the same name.
43044
- let symbol = getReferencedSymbol (node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); // >> change here
43044
+ let symbol = getReferencedValueSymbol (node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node));
43045
43045
if (symbol) {
43046
43046
if (symbol.flags & SymbolFlags.ExportValue) {
43047
43047
// If we reference an exported entity within the same module declaration, then whether
@@ -43077,6 +43077,7 @@ namespace ts {
43077
43077
const node = getParseTreeNode(nodeIn, isIdentifier);
43078
43078
if (node) {
43079
43079
const symbol = getReferencedSymbol(node, /*startInDeclarationContainer*/ undefined);
43080
+
43080
43081
// We should only get the declaration of an alias if there isn't a local value
43081
43082
// declaration for the symbol
43082
43083
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !getTypeOnlyAliasDeclaration(symbol)) {
@@ -43461,12 +43462,10 @@ namespace ts {
43461
43462
return globals.has(escapeLeadingUnderscores(name));
43462
43463
}
43463
43464
43464
- function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean, useCache = true): Symbol | undefined { // >> TODO: if we change this to return any kind of symbol, then rename it
43465
- if (useCache) {
43466
- const resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
43467
- if (resolvedSymbol) {
43468
- return resolvedSymbol;
43469
- }
43465
+ function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol | undefined {
43466
+ const resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
43467
+ if (resolvedSymbol) {
43468
+ return resolvedSymbol;
43470
43469
}
43471
43470
43472
43471
let location: Node = reference;
@@ -43482,7 +43481,14 @@ namespace ts {
43482
43481
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
43483
43482
}
43484
43483
43485
- function getReferencedSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol | undefined { // >> TODO
43484
+ /**
43485
+ * Get either a value-meaning symbol or an alias symbol.
43486
+ * Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
43487
+ * we call `resolveName` to find a symbol.
43488
+ * This is because when caching the resolved symbol, we only consider value symbols, but here
43489
+ * we want to also get an alias symbol if one exists.
43490
+ */
43491
+ function getReferencedSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol | undefined {
43486
43492
const resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
43487
43493
if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
43488
43494
return resolvedSymbol;
@@ -43498,10 +43504,6 @@ namespace ts {
43498
43504
}
43499
43505
}
43500
43506
43501
- // >> TODO: this comment is only valid for the use of 'getReferencedSymbol' in 'getReferencedImportDeclaration'.
43502
- // We get the symbol that has a value meaning, or is an alias.
43503
- // We'll only ever want a symbol that doesn't have a value meaning if it is also an import,
43504
- // and therefore if it has an alias meaning (because those type-resolving imports are not always elided e.g. in JS).
43505
43507
return resolveName(
43506
43508
location,
43507
43509
reference.escapedText,
0 commit comments