mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-01 14:25:16 -05:00
Don't delete comments when deleting unused declarations (#37467)
* don't delete comment on variable declaration * add more declaration kinds * don't copy comment in convertes6 class * don't copy comments in convertToES6Class * add tests * use isAnyImportSyntax * handle mixed comment types * update tests
This commit is contained in:
@@ -48,7 +48,10 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile);
|
||||
// Deleting a declaration only deletes JSDoc style comments, so only copy those to the new node.
|
||||
if (hasJSDocNodes(ctorDeclaration)) {
|
||||
copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile);
|
||||
}
|
||||
|
||||
// Because the preceding node could be touched, we need to insert nodes before delete nodes.
|
||||
changes.insertNodeAfter(sourceFile, precedingNode!, newClassDeclaration);
|
||||
|
||||
Reference in New Issue
Block a user