diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index d5db98a1d30..4d6eb8f7a99 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -129,7 +129,7 @@ namespace ts.formatting { // Async-await rule("SpaceBetweenAsyncAndOpenParen", SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken, [isArrowFunctionContext, isNonJsxSameLineTokenContext], RuleAction.InsertSpace), - rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, [SyntaxKind.FunctionKeyword, SyntaxKind.Identifier], [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), // Template string rule("NoSpaceBetweenTagAndTemplateString", [SyntaxKind.Identifier, SyntaxKind.CloseParenToken], [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.DeleteSpace), diff --git a/tests/cases/fourslash/formatAsyncClassMethod1.ts b/tests/cases/fourslash/formatAsyncClassMethod1.ts new file mode 100644 index 00000000000..b120a8c771e --- /dev/null +++ b/tests/cases/fourslash/formatAsyncClassMethod1.ts @@ -0,0 +1,12 @@ +/// + +////class Foo { +//// async foo() {} +////} + +format.document(); +verify.currentFileContentIs( +`class Foo { + async foo() { } +}` +); diff --git a/tests/cases/fourslash/formatAsyncClassMethod2.ts b/tests/cases/fourslash/formatAsyncClassMethod2.ts new file mode 100644 index 00000000000..6901778b0a6 --- /dev/null +++ b/tests/cases/fourslash/formatAsyncClassMethod2.ts @@ -0,0 +1,12 @@ +/// + +////class Foo { +//// private async foo() {} +////} + +format.document(); +verify.currentFileContentIs( +`class Foo { + private async foo() { } +}` +);