@@ -804,16 +804,8 @@ namespace ts {
804804 break;
805805 }
806806
807- switch (declaration.parent.parent.kind) {
808- case SyntaxKind.ForInStatement:
809- case SyntaxKind.ForOfStatement:
810- // ForIn/ForOf case - use site should not be used in expression part
811- if (isSameScopeDescendentOf(usage, (<ForInStatement | ForOfStatement>declaration.parent.parent).expression, container)) {
812- return true;
813- }
814- }
815-
816- return false;
807+ // ForIn/ForOf case - use site should not be used in expression part
808+ return isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container);
817809 }
818810
819811 function isUsedInFunctionOrInstanceProperty(usage: Node, declaration: Node, container?: Node): boolean {
@@ -19588,9 +19580,7 @@ namespace ts {
1958819580 function errorUnusedLocal(node: Node, name: string) {
1958919581 if (isIdentifierThatStartsWithUnderScore(node)) {
1959019582 const declaration = getRootDeclaration(node.parent);
19591- if (declaration.kind === SyntaxKind.VariableDeclaration &&
19592- (declaration.parent.parent.kind === SyntaxKind.ForInStatement ||
19593- declaration.parent.parent.kind === SyntaxKind.ForOfStatement)) {
19583+ if (declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) {
1959419584 return;
1959519585 }
1959619586 }
@@ -20283,7 +20273,7 @@ namespace ts {
2028320273 }
2028420274 }
2028520275
20286- function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement ): void {
20276+ function checkForInOrForOfVariableDeclaration(iterationStatement: ForInOrOfStatement ): void {
2028720277 const variableDeclarationList = <VariableDeclarationList>iterationStatement.initializer;
2028820278 // checkGrammarForInOrForOfStatement will check that there is exactly one declaration.
2028920279 if (variableDeclarationList.declarations.length >= 1) {
@@ -24263,7 +24253,7 @@ namespace ts {
2426324253 }
2426424254 }
2426524255
24266- function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInStatement | ForOfStatement ): boolean {
24256+ function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInOrOfStatement ): boolean {
2426724257 if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
2426824258 return true;
2426924259 }
0 commit comments