@@ -1056,9 +1056,10 @@ namespace ts {
10561056 // block-scoped variable and namespace module. However, only when we
10571057 // try to resolve name in /*1*/ which is used in variable position,
10581058 // 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)) {
10601061 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 ) {
10621063 checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
10631064 }
10641065 }
@@ -1171,19 +1172,22 @@ namespace ts {
11711172 }
11721173
11731174 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 ));
11751176 // 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);
11771178
1178- Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
1179+ Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined");
11791180
11801181 if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
11811182 if (result.flags & SymbolFlags.BlockScopedVariable) {
11821183 error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
11831184 }
1184- else {
1185+ else if (result.flags & SymbolFlags.Class) {
11851186 error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name));
11861187 }
1188+ else if (result.flags & SymbolFlags.Enum) {
1189+ error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name));
1190+ }
11871191 }
11881192 }
11891193
0 commit comments