Skip to content

Commit 2c13bae

Browse files
committed
fix(formatter): correct printing remaining trailing comments for TSMappedType
1 parent 2fdc11c commit 2c13bae

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

crates/oxc_formatter/src/formatter/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'a> Comments<'a> {
323323
}
324324

325325
if !source_text.all_bytes_match(start, comment.span.start, |b| {
326-
b.is_ascii_whitespace() || matches!(b, b')' | b',')
326+
b.is_ascii_whitespace() || matches!(b, b')' | b',' | b';')
327327
}) {
328328
return &comments[..idx];
329329
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type _Test = {
2+
[T in number]: T;
3+
// If there are any BinaryOperator members that don't have a corresponding
4+
// BinaryOperatorToText, then this line will error with "Type 'T' cannot
5+
// be used to index type 'BinaryOperatorToText'."
6+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
type _Test = {
6+
[T in number]: T;
7+
// If there are any BinaryOperator members that don't have a corresponding
8+
// BinaryOperatorToText, then this line will error with "Type 'T' cannot
9+
// be used to index type 'BinaryOperatorToText'."
10+
};
11+
12+
==================== Output ====================
13+
type _Test = {
14+
[T in number]: T;
15+
// If there are any BinaryOperator members that don't have a corresponding
16+
// BinaryOperatorToText, then this line will error with "Type 'T' cannot
17+
// be used to index type 'BinaryOperatorToText'."
18+
};
19+
20+
===================== End =====================

0 commit comments

Comments
 (0)