@@ -121,9 +121,26 @@ namespace ts.codefix {
121
121
break ;
122
122
123
123
case SyntaxKind . Parameter :
124
- const functionDeclaration = < FunctionDeclaration > parent . parent ;
125
- if ( functionDeclaration . parameters . length === 1 ) {
126
- changes . deleteNode ( sourceFile , parent ) ;
124
+ const oldFunction = parent . parent ;
125
+ if ( isArrowFunction ( oldFunction ) && oldFunction . parameters . length === 1 ) {
126
+ // Lambdas with exactly one parameter are special because, after removal, there
127
+ // must be an empty parameter list (i.e. `()`) and this won't necessarily be the
128
+ // case if the parameter is simply removed (e.g. in `x => 1`).
129
+ const newFunction = updateArrowFunction (
130
+ oldFunction ,
131
+ oldFunction . modifiers ,
132
+ oldFunction . typeParameters ,
133
+ /*parameters*/ undefined ,
134
+ oldFunction . type ,
135
+ oldFunction . equalsGreaterThanToken ,
136
+ oldFunction . body ) ;
137
+
138
+ // Drop leading and trailing trivia of the new function because we're only going
139
+ // to replace the span (vs the full span) of the old function - the old leading
140
+ // and trailing trivia will remain.
141
+ suppressLeadingAndTrailingTrivia ( newFunction ) ;
142
+
143
+ changes . replaceRange ( sourceFile , { pos : oldFunction . getStart ( ) , end : oldFunction . end } , newFunction ) ;
127
144
}
128
145
else {
129
146
changes . deleteNodeInList ( sourceFile , parent ) ;
0 commit comments