@@ -276,11 +276,15 @@ namespace ts.textChanges {
276276 return this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , options ) , newNodes , options ) ;
277277 }
278278
279+ public replaceNodeWithText ( sourceFile : SourceFile , oldNode : Node , text : string ) : void {
280+ this . replaceRangeWithText ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , useNonAdjustedPositions ) , text ) ;
281+ }
282+
279283 public replaceNodeRangeWithNodes ( sourceFile : SourceFile , startNode : Node , endNode : Node , newNodes : ReadonlyArray < Node > , options : ReplaceWithMultipleNodesOptions & ConfigurableStartEnd = useNonAdjustedPositions ) {
280284 return this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , startNode , endNode , options ) , newNodes , options ) ;
281285 }
282286
283- private nextCommaToken ( sourceFile : SourceFile , node : Node ) : Node | undefined {
287+ private nextCommaToken ( sourceFile : SourceFile , node : Node ) : Node | undefined {
284288 const next = findNextToken ( node , node . parent , sourceFile ) ;
285289 return next && next . kind === SyntaxKind . CommaToken ? next : undefined ;
286290 }
@@ -690,7 +694,7 @@ namespace ts.textChanges {
690694 }
691695
692696 private finishDeleteDeclarations ( ) : void {
693- const deletedNodesInLists = new NodeSet ( ) ; // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
697+ const deletedNodesInLists = new NodeSet ( ) ; // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
694698 for ( const { sourceFile, node } of this . deletedNodes ) {
695699 if ( ! this . deletedNodes . some ( d => d . sourceFile === sourceFile && rangeContainsRangeExclusive ( d . node , node ) ) ) {
696700 if ( isArray ( node ) ) {
@@ -1053,25 +1057,13 @@ namespace ts.textChanges {
10531057 switch ( node . kind ) {
10541058 case SyntaxKind . Parameter : {
10551059 const oldFunction = node . parent ;
1056- if ( isArrowFunction ( oldFunction ) && oldFunction . parameters . length === 1 ) {
1060+ if ( isArrowFunction ( oldFunction ) &&
1061+ oldFunction . parameters . length === 1 &&
1062+ ! findChildOfKind ( oldFunction , SyntaxKind . OpenParenToken , sourceFile ) ) {
10571063 // Lambdas with exactly one parameter are special because, after removal, there
10581064 // must be an empty parameter list (i.e. `()`) and this won't necessarily be the
10591065 // case if the parameter is simply removed (e.g. in `x => 1`).
1060- const newFunction = updateArrowFunction (
1061- oldFunction ,
1062- oldFunction . modifiers ,
1063- oldFunction . typeParameters ,
1064- /*parameters*/ undefined ! , // TODO: GH#18217
1065- oldFunction . type ,
1066- oldFunction . equalsGreaterThanToken ,
1067- oldFunction . body ) ;
1068-
1069- // Drop leading and trailing trivia of the new function because we're only going
1070- // to replace the span (vs the full span) of the old function - the old leading
1071- // and trailing trivia will remain.
1072- suppressLeadingAndTrailingTrivia ( newFunction ) ;
1073-
1074- changes . replaceNode ( sourceFile , oldFunction , newFunction ) ;
1066+ changes . replaceNodeWithText ( sourceFile , node , "()" ) ;
10751067 }
10761068 else {
10771069 deleteNodeInList ( changes , deletedNodesInLists , sourceFile , node ) ;
0 commit comments