From a8846bf12c75f299eced2fb1e864b421efcc3878 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 8 Jun 2017 13:45:21 -0700 Subject: [PATCH] Skip block scope check with no error location An example of a symbol with no error location is a global symbol like Promise. --- src/compiler/checker.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a9c02fea04..8158e5ecad8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1116,7 +1116,7 @@ namespace ts { return undefined; } - // Only check for block-scoped variable if we are looking for the + // Only check for block-scoped variable if we have an error location and are looking for the // name with variable meaning // For example, // declare module foo { @@ -1127,8 +1127,9 @@ namespace ts { // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & SymbolFlags.BlockScopedVariable || - ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) { + if (errorLocation && + (meaning & SymbolFlags.BlockScopedVariable || + ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value))) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);