diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 4c4213ee2e9..8d9032a6d48 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -226,6 +226,7 @@ import { isRequireVariableStatement, isRightSideOfQualifiedNameOrPropertyAccess, isRootedDiskPath, + isSatisfiesExpression, isSetAccessorDeclaration, isSourceFile, isSourceFileJS, @@ -3355,7 +3356,7 @@ function indexInTextChange(change: string, name: string): number { export function needsParentheses(expression: Expression): boolean { return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression) - || isAsExpression(expression) && isObjectLiteralExpression(expression.expression); + || (isAsExpression(expression) || isSatisfiesExpression(expression)) && isObjectLiteralExpression(expression.expression); } /** @internal */ diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction35.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction35.ts new file mode 100644 index 00000000000..eb2a70643c9 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction35.ts @@ -0,0 +1,13 @@ +/// + +/////*a*/()/*b*/ => { +//// return {} satisfies any +////} + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: "() => ({} satisfies any)", +});