@@ -1781,8 +1781,9 @@ namespace ts {
1781
1781
nameNotFoundMessage: DiagnosticMessage | undefined,
1782
1782
nameArg: __String | Identifier | undefined,
1783
1783
isUse: boolean,
1784
- excludeGlobals = false): Symbol | undefined {
1785
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol);
1784
+ excludeGlobals = false,
1785
+ getSpellingSuggstions = true): Symbol | undefined {
1786
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
1786
1787
}
1787
1788
1788
1789
function resolveNameHelper(
@@ -1793,6 +1794,7 @@ namespace ts {
1793
1794
nameArg: __String | Identifier | undefined,
1794
1795
isUse: boolean,
1795
1796
excludeGlobals: boolean,
1797
+ getSpellingSuggestions: boolean,
1796
1798
lookup: typeof getSymbol): Symbol | undefined {
1797
1799
const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
1798
1800
let result: Symbol | undefined;
@@ -2132,7 +2134,7 @@ namespace ts {
2132
2134
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
2133
2135
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
2134
2136
let suggestion: Symbol | undefined;
2135
- if (suggestionCount < maximumSuggestionCount) {
2137
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
2136
2138
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
2137
2139
const isGlobalScopeAugmentationDeclaration = suggestion?.valueDeclaration && isAmbientModule(suggestion.valueDeclaration) && isGlobalScopeAugmentation(suggestion.valueDeclaration);
2138
2140
if (isGlobalScopeAugmentationDeclaration) {
@@ -13657,7 +13659,7 @@ namespace ts {
13657
13659
13658
13660
function getGlobalSymbol(name: __String, meaning: SymbolFlags, diagnostic: DiagnosticMessage | undefined): Symbol | undefined {
13659
13661
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
13660
- return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
13662
+ return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false );
13661
13663
}
13662
13664
13663
13665
function getGlobalType(name: __String, arity: 0, reportErrors: true): ObjectType;
@@ -28718,7 +28720,7 @@ namespace ts {
28718
28720
28719
28721
function getSuggestedSymbolForNonexistentSymbol(location: Node | undefined, outerName: __String, meaning: SymbolFlags): Symbol | undefined {
28720
28722
Debug.assert(outerName !== undefined, "outername should always be defined");
28721
- const result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, (symbols, name, meaning) => {
28723
+ const result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, (symbols, name, meaning) => {
28722
28724
Debug.assertEqual(outerName, name, "name should equal outerName");
28723
28725
const symbol = getSymbol(symbols, name, meaning);
28724
28726
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
@@ -28816,8 +28818,7 @@ namespace ts {
28816
28818
return candidateName;
28817
28819
}
28818
28820
28819
- // Don't try to resolve aliases if global types aren't initialized yet
28820
- if (globalObjectType && candidate.flags & SymbolFlags.Alias) {
28821
+ if (candidate.flags & SymbolFlags.Alias) {
28821
28822
const alias = tryResolveAlias(candidate);
28822
28823
if (alias && alias.flags & meaning) {
28823
28824
return candidateName;
0 commit comments