Skip to content

Commit 72a0411

Browse files
authored
fix(37431): allow only one space between async keyword and method name (#37504)
1 parent 78a9924 commit 72a0411

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/services/formatting/rules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace ts.formatting {
129129

130130
// Async-await
131131
rule("SpaceBetweenAsyncAndOpenParen", SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken, [isArrowFunctionContext, isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
132-
rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
132+
rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, [SyntaxKind.FunctionKeyword, SyntaxKind.Identifier], [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
133133

134134
// Template string
135135
rule("NoSpaceBetweenTagAndTemplateString", [SyntaxKind.Identifier, SyntaxKind.CloseParenToken], [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="fourslash.ts"/>
2+
3+
////class Foo {
4+
//// async foo() {}
5+
////}
6+
7+
format.document();
8+
verify.currentFileContentIs(
9+
`class Foo {
10+
async foo() { }
11+
}`
12+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="fourslash.ts"/>
2+
3+
////class Foo {
4+
//// private async foo() {}
5+
////}
6+
7+
format.document();
8+
verify.currentFileContentIs(
9+
`class Foo {
10+
private async foo() { }
11+
}`
12+
);

0 commit comments

Comments
 (0)