Skip to content

Commit 4c5dbda

Browse files
committed
fix type parens regression
1 parent 1cf8108 commit 4c5dbda

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/generation/generate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6655,6 +6655,10 @@ fn should_skip_parenthesized_type<'a>(node: &'a TSParenthesizedType<'a>, context
66556655
}
66566656
}
66576657

6658+
if matches!(context.parent(), Node::TSArrayType(_)) {
6659+
return false;
6660+
}
6661+
66586662
if context.token_finder.get_previous_token_if_colon(node).is_some() {
66596663
return true;
66606664
}

tests/specs/types/ArrayType/ArrayType_All.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,27 @@ type Test = test | (string | number | other)[ ];
1212
type Test =
1313
| test
1414
| (string | number | other)[];
15+
16+
== should keep parens for array of union return type ==
17+
const test = ({
18+
ref,
19+
}): (
20+
| Builder<number>
21+
| "revision_id"
22+
| Builder<string>
23+
)[] => [
24+
ref("iteration"),
25+
"revision_id",
26+
];
27+
28+
[expect]
29+
const test = ({
30+
ref,
31+
}): (
32+
| Builder<number>
33+
| "revision_id"
34+
| Builder<string>
35+
)[] => [
36+
ref("iteration"),
37+
"revision_id",
38+
];

0 commit comments

Comments
 (0)