Skip to content

Commit

Permalink
Fix parens detection for object&function in as/satisfies (#16648)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored Jul 16, 2024
1 parent ddfd86c commit dcee3e4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/babel-generator/src/node/parentheses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ function isFirstInContext(
((parentType === "BinaryExpression" ||
parentType === "LogicalExpression") &&
parent.left === node) ||
(parentType === "AssignmentExpression" && parent.left === node))
(parentType === "AssignmentExpression" && parent.left === node) ||
((parentType === "TSAsExpression" ||
parentType === "TSSatisfiesExpression") &&
parent.expression === node))
) {
node = parent;
i--;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
() => ({} as x);
() => ({} satisfies x);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
() => ({}) as x;
() => ({}) satisfies x;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (function f() {} as x);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (function f() {}) as x;

0 comments on commit dcee3e4

Please sign in to comment.