Skip to content

Commit cc87e29

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 b94c513 commit cc87e29

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
@@ -1124,7 +1124,7 @@ namespace ts {
11241124
return undefined;
11251125
}
11261126

1127-
// Only check for block-scoped variable if we are looking for the
1127+
// Only check for block-scoped variable if we have an error location and are looking for the
11281128
// name with variable meaning
11291129
// For example,
11301130
// declare module foo {
@@ -1135,8 +1135,9 @@ namespace ts {
11351135
// block-scoped variable and namespace module. However, only when we
11361136
// try to resolve name in /*1*/ which is used in variable position,
11371137
// we want to check for block-scoped
1138-
if (meaning & SymbolFlags.BlockScopedVariable ||
1139-
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
1138+
if (errorLocation &&
1139+
(meaning & SymbolFlags.BlockScopedVariable ||
1140+
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value))) {
11401141
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
11411142
if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) {
11421143
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);

0 commit comments

Comments
 (0)