mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Fix indentation of arrow functions returning parenthesized expressions (#40677)
* Fix indentation of arrow functions returning parenthesized expressions * Add more test cases
This commit is contained in:
@@ -2461,8 +2461,7 @@ namespace FourSlash {
|
||||
const { fileName } = this.activeFile;
|
||||
const before = this.getFileContent(fileName);
|
||||
this.formatDocument();
|
||||
const after = this.getFileContent(fileName);
|
||||
this.assertObjectsEqual(after, before);
|
||||
this.verifyFileContent(fileName, before);
|
||||
}
|
||||
|
||||
public verifyTextAtCaretIs(text: string) {
|
||||
|
||||
@@ -558,11 +558,15 @@ namespace ts.formatting {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return childKind !== SyntaxKind.Block;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (sourceFile && childKind === SyntaxKind.ParenthesizedExpression) {
|
||||
return rangeIsOnOneLine(sourceFile, child!);
|
||||
}
|
||||
return childKind !== SyntaxKind.Block;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return childKind !== SyntaxKind.NamedExports;
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
|
||||
Reference in New Issue
Block a user