@@ -214,6 +214,7 @@ namespace ts.formatting {
214214 public SpaceBetweenYieldOrYieldStarAndOperand : Rule ;
215215
216216 // Async functions
217+ public SpaceBetweenAsyncAndOpenParen : Rule ;
217218 public SpaceBetweenAsyncAndFunctionKeyword : Rule ;
218219
219220 // Template strings
@@ -369,6 +370,7 @@ namespace ts.formatting {
369370 this . SpaceBetweenYieldOrYieldStarAndOperand = new Rule ( RuleDescriptor . create4 ( Shared . TokenRange . FromTokens ( [ SyntaxKind . YieldKeyword , SyntaxKind . AsteriskToken ] ) , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSameLineTokenContext , Rules . IsYieldOrYieldStarWithOperand ) , RuleAction . Space ) ) ;
370371
371372 // Async-await
373+ this . SpaceBetweenAsyncAndOpenParen = new Rule ( RuleDescriptor . create1 ( SyntaxKind . AsyncKeyword , SyntaxKind . OpenParenToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsArrowFunctionContext , Rules . IsSameLineTokenContext ) , RuleAction . Space ) ) ;
372374 this . SpaceBetweenAsyncAndFunctionKeyword = new Rule ( RuleDescriptor . create1 ( SyntaxKind . AsyncKeyword , SyntaxKind . FunctionKeyword ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSameLineTokenContext ) , RuleAction . Space ) ) ;
373375
374376 // template string
@@ -402,7 +404,7 @@ namespace ts.formatting {
402404 this . NoSpaceBeforeOpenParenInFuncCall ,
403405 this . SpaceBeforeBinaryKeywordOperator , this . SpaceAfterBinaryKeywordOperator ,
404406 this . SpaceAfterVoidOperator ,
405- this . SpaceBetweenAsyncAndFunctionKeyword ,
407+ this . SpaceBetweenAsyncAndOpenParen , this . SpaceBetweenAsyncAndFunctionKeyword ,
406408 this . SpaceBetweenTagAndTemplateString , this . NoSpaceAfterTemplateHeadAndMiddle , this . NoSpaceBeforeTemplateMiddleAndTail ,
407409
408410 // TypeScript-specific rules
@@ -703,6 +705,10 @@ namespace ts.formatting {
703705 return context . currentTokenSpan . kind !== SyntaxKind . CommaToken ;
704706 }
705707
708+ static IsArrowFunctionContext ( context : FormattingContext ) : boolean {
709+ return context . contextNode . kind === SyntaxKind . ArrowFunction ;
710+ }
711+
706712 static IsSameLineTokenContext ( context : FormattingContext ) : boolean {
707713 return context . TokensAreOnSameLine ( ) ;
708714 }
0 commit comments