Skip to content

Commit 206b519

Browse files
committed
fix(formatter): should hug parameter with TSMappedType type annotation (#15049)
1 parent e48c604 commit 206b519

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

crates/oxc_formatter/src/write/parameters.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ pub fn should_hug_function_parameters<'a>(
356356
BindingPatternKind::BindingIdentifier(_) => {
357357
parentheses_not_needed
358358
|| only_parameter.pattern.type_annotation.as_ref().is_some_and(|ann| {
359-
matches!(&ann.type_annotation, TSType::TSTypeLiteral(literal))
359+
matches!(
360+
&ann.type_annotation,
361+
TSType::TSTypeLiteral(_) | TSType::TSMappedType(_)
362+
)
360363
})
361364
}
362365
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const assertFilteringFor = (expected: {
2+
[T in TestFilterTerm]?: boolean;
3+
}) => {};
4+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
const assertFilteringFor = (expected: {
6+
[T in TestFilterTerm]?: boolean;
7+
}) => {};
8+
9+
==================== Output ====================
10+
const assertFilteringFor = (expected: {
11+
[T in TestFilterTerm]?: boolean;
12+
}) => {};
13+
14+
===================== End =====================

0 commit comments

Comments
 (0)