diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 16270eda479..f6a9dee4cfe 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -321,6 +321,9 @@ namespace ts.formatting { rule("NoSpaceAfterCloseBracket", SyntaxKind.CloseBracketToken, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], RuleAction.Delete), rule("SpaceAfterSemicolon", SyntaxKind.SemicolonToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + // Remove extra space between for and await + rule("SpaceBetweenForAndAwaitKeyword", SyntaxKind.ForKeyword, SyntaxKind.AwaitKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), + // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] rule( diff --git a/tests/cases/fourslash/formattingAwait.ts b/tests/cases/fourslash/formattingAwait.ts new file mode 100644 index 00000000000..e6a86f92d08 --- /dev/null +++ b/tests/cases/fourslash/formattingAwait.ts @@ -0,0 +1,18 @@ +/// + +////async function f() { +//// for await (const x of g()) { +//// console.log(x); +//// } +////} + + +format.document(); + +verify.currentFileContentIs( +`async function f() { + for await (const x of g()) { + console.log(x); + } +}` +); \ No newline at end of file