mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Do not report unused local error on locals that are intended for removing properties with object spread
Fixes #12766
This commit is contained in:
@@ -16702,6 +16702,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isRemovedPropertyFromObjectSpread(node: Node) {
|
||||
if (isBindingElement(node) && isObjectBindingPattern(node.parent)) {
|
||||
const lastElement = lastOrUndefined(node.parent.elements);
|
||||
return lastElement !== node && !!lastElement.dotDotDotToken;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function errorUnusedLocal(node: Node, name: string) {
|
||||
if (isIdentifierThatStartsWithUnderScore(node)) {
|
||||
const declaration = getRootDeclaration(node.parent);
|
||||
@@ -16711,7 +16719,10 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
}
|
||||
error(node, Diagnostics._0_is_declared_but_never_used, name);
|
||||
|
||||
if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) {
|
||||
error(node, Diagnostics._0_is_declared_but_never_used, name);
|
||||
}
|
||||
}
|
||||
|
||||
function parameterNameStartsWithUnderscore(parameterName: DeclarationName) {
|
||||
|
||||
Reference in New Issue
Block a user