mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 17:05:58 -05:00
Fix formatting between for and await (#21254)
* Fix issue 21084 * Removed unwanted rules.
This commit is contained in:
committed by
Mohamed Hegazy
parent
a7c53c70d2
commit
92bde084c1
@@ -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(
|
||||
|
||||
18
tests/cases/fourslash/formattingAwait.ts
Normal file
18
tests/cases/fourslash/formattingAwait.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////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);
|
||||
}
|
||||
}`
|
||||
);
|
||||
Reference in New Issue
Block a user