prefix-unused-parameter-with-_ codefix now works in jsdoc @param (#36152)

* Fix prepending unused TypeScript variables with underscore doesn't rename JSDoc @param.
Fix test for quick fix "Prefix all unused declarations with '_' where possible".
Fixes #33021.

* Replace FindAllReferences.Core.eachSymbolReferenceInFile function call to more ligher call of getJSDocParameterTags when searching for a parameter in jsdoc.

* Remove redundant constant declaration.

* Add test for prefix single unused parameter in jsdoc.
This commit is contained in:
sergeir82
2020-04-17 23:18:05 +03:00
committed by GitHub
parent deb5bac520
commit b346f5764e
3 changed files with 41 additions and 1 deletions

View File

@@ -154,6 +154,13 @@ namespace ts.codefix {
}
if (isIdentifier(token) && canPrefix(token)) {
changes.replaceNode(sourceFile, token, createIdentifier(`_${token.text}`));
if (isParameter(token.parent)) {
getJSDocParameterTags(token.parent).forEach((tag) => {
if (isIdentifier(tag.name)) {
changes.replaceNode(sourceFile, tag.name, createIdentifier(`_${tag.name.text}`));
}
});
}
}
}