Skip to content

Commit 43ecac8

Browse files
authored
fix(52386): JSDoc code fixes for arrow-function initialized const duplicates comment (microsoft#52390)
1 parent 7f64af2 commit 43ecac8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/services/codefixes/fixUnmatchedParameter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function getDeleteAction(context: CodeFixContext, { name, jsDocHost, jsDocParame
8383
);
8484
}
8585

86-
function getRenameAction(context: CodeFixContext, { name, signature, jsDocParameterTag }: Info) {
86+
function getRenameAction(context: CodeFixContext, { name, jsDocHost, signature, jsDocParameterTag }: Info) {
8787
if (!length(signature.parameters)) return undefined;
8888

8989
const sourceFile = context.sourceFile;
@@ -110,7 +110,7 @@ function getRenameAction(context: CodeFixContext, { name, signature, jsDocParame
110110
jsDocParameterTag.comment
111111
);
112112
const changes = textChanges.ChangeTracker.with(context, changeTracker =>
113-
changeTracker.replaceJSDocComment(sourceFile, signature, map(tags, t => t === jsDocParameterTag ? newJSDocParameterTag : t)));
113+
changeTracker.replaceJSDocComment(sourceFile, jsDocHost, map(tags, t => t === jsDocParameterTag ? newJSDocParameterTag : t)));
114114
return createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
115115
}
116116

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @filename: /a.ts
4+
/////**
5+
//// * @param {string} y
6+
//// * @returns
7+
//// */
8+
////export const foo = (x: string) => x;
9+
10+
verify.codeFix({
11+
description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "y", "x"],
12+
index: 1,
13+
newFileContent:
14+
`/**
15+
* @param {string} x
16+
* @returns
17+
*/
18+
export const foo = (x: string) => x;`,
19+
});

0 commit comments

Comments
 (0)