@@ -1056,9 +1056,10 @@ namespace ts {
1056
1056
// block-scoped variable and namespace module. However, only when we
1057
1057
// try to resolve name in /*1*/ which is used in variable position,
1058
1058
// we want to check for block-scoped
1059
- if (meaning & SymbolFlags.BlockScopedVariable || (meaning & SymbolFlags.Class && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
1059
+ if (meaning & SymbolFlags.BlockScopedVariable ||
1060
+ ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
1060
1061
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
1061
- if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class) {
1062
+ if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum ) {
1062
1063
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
1063
1064
}
1064
1065
}
@@ -1171,19 +1172,22 @@ namespace ts {
1171
1172
}
1172
1173
1173
1174
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
1174
- Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class));
1175
+ Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum ));
1175
1176
// Block-scoped variables cannot be used before their definition
1176
- const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) ? d : undefined);
1177
+ const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined);
1177
1178
1178
- Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
1179
+ Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined");
1179
1180
1180
1181
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
1181
1182
if (result.flags & SymbolFlags.BlockScopedVariable) {
1182
1183
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
1183
1184
}
1184
- else {
1185
+ else if (result.flags & SymbolFlags.Class) {
1185
1186
error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name));
1186
1187
}
1188
+ else if (result.flags & SymbolFlags.Enum) {
1189
+ error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name));
1190
+ }
1187
1191
}
1188
1192
}
1189
1193
0 commit comments