Skip to content

Commit

Permalink
fix(migrations): remove setting that removes comments in CF migration (
Browse files Browse the repository at this point in the history
…#53350)

This setting was added to prevent comment duplication, since the TS AST printer includes prior line comments as part of a given line with no way to really avoid that.
However in component imports, it is not safe to remove comments as they could be load bearing for some.

PR Close #53350
  • Loading branch information
thePunderWoman authored and dylhunn committed Dec 5, 2023
1 parent 0a53f96 commit 0db75ab
Showing 1 changed file with 1 addition and 7 deletions.
Expand Up @@ -78,13 +78,7 @@ function updateImportClause(clause: ts.ImportClause, removeCommonModule: boolean

function updateClassImports(
propAssignment: ts.PropertyAssignment, removeCommonModule: boolean): string|null {
// removeComments is set to true to prevent duplication of comments
// when the import declaration is at the top of the file, but right after a comment
// without this, the comment gets duplicated when the declaration is updated.
// the typescript AST includes that preceding comment as part of the import declaration full text.
const printer = ts.createPrinter({
removeComments: true,
});
const printer = ts.createPrinter();
const importList = propAssignment.initializer as ts.ArrayLiteralExpression;
const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
const elements = importList.elements.filter(el => !removals.includes(el.getText()));
Expand Down

0 comments on commit 0db75ab

Please sign in to comment.