Fix "Cannot find name 'global'. Did you mean 'global'?" (#42262)

* Add tests for "Cannot find name 'global'. Did you mean 'global'?"

* Fix "Cannot find name 'global'. Did you mean 'global'?"

* Add an additional test case for spelling suggestions of "global".

* Name the boolean for suggestions being global scope augmentations.
This commit is contained in:
Matt Kantor authored and GitHub committed 2021-01-20 15:23:34 -08:00
1 parent 0383b5cb4c
commit 424b805d61
21 files changed
+184

No files matched your search

+4
View File
@@ -2028,6 +2028,10 @@ namespace ts {
let suggestion: Symbol | undefined;
if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
const isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && isAmbientModule(suggestion.valueDeclaration) && isGlobalScopeAugmentation(suggestion.valueDeclaration);
if (isGlobalScopeAugmentationDeclaration) {
suggestion = undefined;
}
if (suggestion) {
const suggestionName = symbolToString(suggestion);
const diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg!), suggestionName);