From 0069bd10b5541ab48dfaff8d6502aa3873aeff93 Mon Sep 17 00:00:00 2001 From: Jessica Janiuk Date: Mon, 4 Dec 2023 10:18:31 -0500 Subject: [PATCH] fix(migrations): remove setting that removes comments in CF migration 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. --- .../schematics/ng-generate/control-flow-migration/util.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/core/schematics/ng-generate/control-flow-migration/util.ts b/packages/core/schematics/ng-generate/control-flow-migration/util.ts index 048ebf79ae98..86b7e2b692b8 100644 --- a/packages/core/schematics/ng-generate/control-flow-migration/util.ts +++ b/packages/core/schematics/ng-generate/control-flow-migration/util.ts @@ -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()));