Don't add diagnostic on unused import starting with underscore (#24958)

* Don't add diagnostic on unused import starting with underscore

* Fix lint
This commit is contained in:
Andy
2018-06-14 12:55:12 -07:00
committed by GitHub
parent a56b272d38
commit 345012e29d
6 changed files with 54 additions and 35 deletions

View File

@@ -22895,7 +22895,11 @@ namespace ts {
}
for (const declaration of local.declarations) {
if (isAmbientModule(declaration)) continue;
if (isAmbientModule(declaration) ||
(isVariableDeclaration(declaration) && isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name!)) {
continue;
}
if (isImportedDeclaration(declaration)) {
addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
}
@@ -22907,9 +22911,7 @@ namespace ts {
}
}
else if (isVariableDeclaration(declaration)) {
if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !isForInOrOfStatement(declaration.parent.parent)) {
addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
}
addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
}
else {
const parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);