Skip to content

Commit ec2acc9

Browse files
authored
fix(55823) - Remove Braces From Arrow function fails when using satisfies (#55831)
1 parent c5cd275 commit ec2acc9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/services/utilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ import {
226226
isRequireVariableStatement,
227227
isRightSideOfQualifiedNameOrPropertyAccess,
228228
isRootedDiskPath,
229+
isSatisfiesExpression,
229230
isSetAccessorDeclaration,
230231
isSourceFile,
231232
isSourceFileJS,
@@ -3355,7 +3356,7 @@ function indexInTextChange(change: string, name: string): number {
33553356
export function needsParentheses(expression: Expression): boolean {
33563357
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken
33573358
|| isObjectLiteralExpression(expression)
3358-
|| isAsExpression(expression) && isObjectLiteralExpression(expression.expression);
3359+
|| (isAsExpression(expression) || isSatisfiesExpression(expression)) && isObjectLiteralExpression(expression.expression);
33593360
}
33603361

33613362
/** @internal */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////*a*/()/*b*/ => {
4+
//// return {} satisfies any
5+
////}
6+
7+
goTo.select("a", "b");
8+
edit.applyRefactor({
9+
refactorName: "Add or remove braces in an arrow function",
10+
actionName: "Remove braces from arrow function",
11+
actionDescription: "Remove braces from arrow function",
12+
newContent: "() => ({} satisfies any)",
13+
});

0 commit comments

Comments
 (0)