Skip to content

Commit a8846bf

Browse files
committed
Skip block scope check with no error location
An example of a symbol with no error location is a global symbol like Promise.
1 parent 44f2336 commit a8846bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ namespace ts {
11161116
return undefined;
11171117
}
11181118

1119-
// Only check for block-scoped variable if we are looking for the
1119+
// Only check for block-scoped variable if we have an error location and are looking for the
11201120
// name with variable meaning
11211121
// For example,
11221122
// declare module foo {
@@ -1127,8 +1127,9 @@ namespace ts {
11271127
// block-scoped variable and namespace module. However, only when we
11281128
// try to resolve name in /*1*/ which is used in variable position,
11291129
// we want to check for block-scoped
1130-
if (meaning & SymbolFlags.BlockScopedVariable ||
1131-
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
1130+
if (errorLocation &&
1131+
(meaning & SymbolFlags.BlockScopedVariable ||
1132+
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value))) {
11321133
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
11331134
if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) {
11341135
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);

0 commit comments

Comments
 (0)