Skip to content

Commit b926da3

Browse files
a-tarasyuksnovader
authored andcommitted
fix(55823) - Remove Braces From Arrow function fails when using satisfies (microsoft#55831)
1 parent da5fe95 commit b926da3

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
@@ -227,6 +227,7 @@ import {
227227
isRequireVariableStatement,
228228
isRightSideOfQualifiedNameOrPropertyAccess,
229229
isRootedDiskPath,
230+
isSatisfiesExpression,
230231
isSetAccessorDeclaration,
231232
isSourceFile,
232233
isSourceFileJS,
@@ -3356,7 +3357,7 @@ function indexInTextChange(change: string, name: string): number {
33563357
export function needsParentheses(expression: Expression): boolean {
33573358
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken
33583359
|| isObjectLiteralExpression(expression)
3359-
|| isAsExpression(expression) && isObjectLiteralExpression(expression.expression);
3360+
|| (isAsExpression(expression) || isSatisfiesExpression(expression)) && isObjectLiteralExpression(expression.expression);
33603361
}
33613362

33623363
/** @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)