mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 12:57:11 -06:00
Special case arrow functions with only parameter unused
Fixes GH #18274
This commit is contained in:
parent
1dcc83e6d2
commit
e354754b2a
@ -121,9 +121,20 @@ namespace ts.codefix {
|
||||
break;
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
const functionDeclaration = <FunctionDeclaration>parent.parent;
|
||||
if (functionDeclaration.parameters.length === 1) {
|
||||
changes.deleteNode(sourceFile, parent);
|
||||
const oldFunction = parent.parent;
|
||||
if (isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) {
|
||||
const newFunction = updateArrowFunction(
|
||||
oldFunction,
|
||||
oldFunction.modifiers,
|
||||
oldFunction.typeParameters,
|
||||
/*parameters*/ undefined,
|
||||
oldFunction.type,
|
||||
oldFunction.equalsGreaterThanToken,
|
||||
oldFunction.body);
|
||||
|
||||
suppressLeadingAndTrailingTrivia(newFunction);
|
||||
|
||||
changes.replaceRange(sourceFile, { pos: oldFunction.getStart(), end: oldFunction.end }, newFunction);
|
||||
}
|
||||
else {
|
||||
changes.deleteNodeInList(sourceFile, parent);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user