Skip to content

Commit 92bde08

Browse files
esakkirajmhegazy
authored andcommitted
Fix formatting between for and await (microsoft#21254)
* Fix issue 21084 * Removed unwanted rules.
1 parent a7c53c7 commit 92bde08

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/services/formatting/rules.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ namespace ts.formatting {
321321
rule("NoSpaceAfterCloseBracket", SyntaxKind.CloseBracketToken, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], RuleAction.Delete),
322322
rule("SpaceAfterSemicolon", SyntaxKind.SemicolonToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Space),
323323

324+
// Remove extra space between for and await
325+
rule("SpaceBetweenForAndAwaitKeyword", SyntaxKind.ForKeyword, SyntaxKind.AwaitKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space),
326+
324327
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
325328
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
326329
rule(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////async function f() {
4+
//// for await (const x of g()) {
5+
//// console.log(x);
6+
//// }
7+
////}
8+
9+
10+
format.document();
11+
12+
verify.currentFileContentIs(
13+
`async function f() {
14+
for await (const x of g()) {
15+
console.log(x);
16+
}
17+
}`
18+
);

0 commit comments

Comments
 (0)