Skip to content

Commit 07ff4b7

Browse files
committed
small fixes and get rid of unnecessary comments
1 parent b5c0ec6 commit 07ff4b7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Diff for: src/compiler/checker.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -43041,7 +43041,7 @@ namespace ts {
4304143041
// declaration, we need to start resolution at the declaration's container.
4304243042
// Otherwise, we could incorrectly resolve the export container as the
4304343043
// 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));
4304543045
if (symbol) {
4304643046
if (symbol.flags & SymbolFlags.ExportValue) {
4304743047
// If we reference an exported entity within the same module declaration, then whether
@@ -43077,6 +43077,7 @@ namespace ts {
4307743077
const node = getParseTreeNode(nodeIn, isIdentifier);
4307843078
if (node) {
4307943079
const symbol = getReferencedSymbol(node, /*startInDeclarationContainer*/ undefined);
43080+
4308043081
// We should only get the declaration of an alias if there isn't a local value
4308143082
// declaration for the symbol
4308243083
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !getTypeOnlyAliasDeclaration(symbol)) {
@@ -43461,12 +43462,10 @@ namespace ts {
4346143462
return globals.has(escapeLeadingUnderscores(name));
4346243463
}
4346343464

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;
4347043469
}
4347143470

4347243471
let location: Node = reference;
@@ -43482,7 +43481,14 @@ namespace ts {
4348243481
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
4348343482
}
4348443483

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 {
4348643492
const resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
4348743493
if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
4348843494
return resolvedSymbol;
@@ -43498,10 +43504,6 @@ namespace ts {
4349843504
}
4349943505
}
4350043506

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).
4350543507
return resolveName(
4350643508
location,
4350743509
reference.escapedText,

0 commit comments

Comments
 (0)