When using the "asi" option for semicolons, formatters will sometimes have to insert a semicolon at the beginning of a line. An example with dprint:
Input
let line1 = 'hello';
// Comment
[].filter(x => x)
Formatted
let line1 = "hello"
// Comment
;[].filter(x => x)
However, if the code is already formatted, dprint will attach the comment to the first statement. Although technically the comment may be contained within the first statement, developers would typically understand the comment to belong to the latter statement and it would nice if dprint could handle this case.
Describe the bug
dprint-plugin-typescript version: 0.88.10
When using the "asi" option for semicolons, formatters will sometimes have to insert a semicolon at the beginning of a line. An example with dprint:
Input
Formatted
However, if the code is already formatted, dprint will attach the comment to the first statement. Although technically the comment may be contained within the first statement, developers would typically understand the comment to belong to the latter statement and it would nice if dprint could handle this case.
Input Code
Expected Output
Actual Output