@@ -466,13 +466,13 @@ module ts {
466
466
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
467
467
// variable statement/for statement case,
468
468
// use site should not be inside variable declaration (initializer of declaration or binding element)
469
- isUsedBeforeDeclaration = isDescendentOf (errorLocation, variableDeclaration, container);
469
+ isUsedBeforeDeclaration = isSameScopeDescendentOf (errorLocation, variableDeclaration, container);
470
470
}
471
471
else if (variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
472
472
variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
473
473
// ForIn/ForOf case - use site should not be used in expression part
474
- var expression = (<ForInStatement>variableDeclaration.parent.parent).expression;
475
- isUsedBeforeDeclaration = isDescendentOf (errorLocation, expression, container);
474
+ var expression = (<ForInStatement | ForOfStatement >variableDeclaration.parent.parent).expression;
475
+ isUsedBeforeDeclaration = isSameScopeDescendentOf (errorLocation, expression, container);
476
476
}
477
477
}
478
478
if (isUsedBeforeDeclaration) {
@@ -484,7 +484,7 @@ module ts {
484
484
* If at any point current node is equal to 'parent' node - return true.
485
485
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
486
486
*/
487
- function isDescendentOf (initial: Node, parent: Node, stopAt: Node): boolean {
487
+ function isSameScopeDescendentOf (initial: Node, parent: Node, stopAt: Node): boolean {
488
488
if (!parent) {
489
489
return false;
490
490
}
0 commit comments