Skip to content

Commit

Permalink
fix: moving a comment to the top node (#49)
Browse files Browse the repository at this point in the history
* fix: moving a comment to the top node

* fix: added moveSyntheticComments, before if statement
  • Loading branch information
Tesmi-Develop authored Oct 18, 2024
1 parent 7845311 commit 4e7d33c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/transformations/transformFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export function transformFile(state: TransformState, file: ts.SourceFile): ts.So

// steal comments from original first statement so that comment directives work properly
if (firstStatement && statements[0]) {
ts.copyComments(firstStatement, statements[0]);
ts.removeAllComments(firstStatement);
const original = ts.getParseTreeNode(firstStatement);

ts.moveSyntheticComments(statements[0], firstStatement);

if (original) {
ts.copyComments(original, statements[0]);
ts.removeAllComments(original);
}
}
}

Expand Down

0 comments on commit 4e7d33c

Please sign in to comment.