fix(52386): JSDoc code fixes for arrow-function initialized const duplicates comment (#52390)

This commit is contained in:
Oleksandr T 2023-01-25 09:42:57 +02:00 committed by GitHub
parent 7f64af2323
commit 43ecac801b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -83,7 +83,7 @@ function getDeleteAction(context: CodeFixContext, { name, jsDocHost, jsDocParame
);
}
function getRenameAction(context: CodeFixContext, { name, signature, jsDocParameterTag }: Info) {
function getRenameAction(context: CodeFixContext, { name, jsDocHost, signature, jsDocParameterTag }: Info) {
if (!length(signature.parameters)) return undefined;
const sourceFile = context.sourceFile;
@ -110,7 +110,7 @@ function getRenameAction(context: CodeFixContext, { name, signature, jsDocParame
jsDocParameterTag.comment
);
const changes = textChanges.ChangeTracker.with(context, changeTracker =>
changeTracker.replaceJSDocComment(sourceFile, signature, map(tags, t => t === jsDocParameterTag ? newJSDocParameterTag : t)));
changeTracker.replaceJSDocComment(sourceFile, jsDocHost, map(tags, t => t === jsDocParameterTag ? newJSDocParameterTag : t)));
return createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
}

View File

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @filename: /a.ts
/////**
//// * @param {string} y
//// * @returns
//// */
////export const foo = (x: string) => x;
verify.codeFix({
description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "y", "x"],
index: 1,
newFileContent:
`/**
* @param {string} x
* @returns
*/
export const foo = (x: string) => x;`,
});