Skip to content

Commit

Permalink
Skip block scope check with no error location
Browse files Browse the repository at this point in the history
An example of a symbol with no error location is a global symbol like
Promise.
  • Loading branch information
sandersn committed Jun 22, 2017
1 parent 44f2336 commit a8846bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/checker.ts
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit a8846bf

Please sign in to comment.