Skip to content

Commit 1ce105a

Browse files
committed
addressed PR feedback
1 parent d3246a3 commit 1ce105a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,13 @@ module ts {
466466
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
467467
// variable statement/for statement case,
468468
// 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);
470470
}
471471
else if (variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
472472
variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
473473
// 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);
476476
}
477477
}
478478
if (isUsedBeforeDeclaration) {
@@ -484,7 +484,7 @@ module ts {
484484
* If at any point current node is equal to 'parent' node - return true.
485485
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
486486
*/
487-
function isDescendentOf(initial: Node, parent: Node, stopAt: Node): boolean {
487+
function isSameScopeDescendentOf(initial: Node, parent: Node, stopAt: Node): boolean {
488488
if (!parent) {
489489
return false;
490490
}

0 commit comments

Comments
 (0)