Fix crash in use-before-def checking of enum tag (#27350) (#27354)

This commit is contained in:
Nathan Shively-Sanders
2018-09-26 09:05:18 -07:00
committed by GitHub
parent b065902a99
commit 4fac5f26dc
4 changed files with 43 additions and 1 deletions

View File

@@ -1711,7 +1711,9 @@ namespace ts {
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum));
// Block-scoped variables cannot be used before their definition
const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined);
const declaration = find(
result.declarations,
d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) || isInJSFile(d) && !!getJSDocEnumTag(d));
if (declaration === undefined) return Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined");