Skip to content

Commit 5d49f98

Browse files
committed
Fixed self-check crash
1 parent 8030e75 commit 5d49f98

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/checker.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2834,8 +2834,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
28342834
return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) ||
28352835
declaration.pos < errorBindingElement.pos;
28362836
}
2837+
const rootDeclaration = getRootDeclaration(declaration) as Declaration;
2838+
if (rootDeclaration.kind !== SyntaxKind.VariableDeclaration) {
2839+
return true;
2840+
}
28372841
// or it might be illegal if usage happens before parent variable is declared (eg var [a] = a)
2838-
return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, SyntaxKind.VariableDeclaration) as Declaration, usage);
2842+
return isBlockScopedNameDeclaredBeforeUse(rootDeclaration, usage);
28392843
}
28402844
else if (declaration.kind === SyntaxKind.VariableDeclaration) {
28412845
// still might be illegal if usage is in the initializer of the variable declaration (eg var a = a)

0 commit comments

Comments
 (0)