mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Allow async as parameter in arrowfunction (#8488)
* Allow async as a parameter name in simple arrow function * Add tests
This commit is contained in:
@@ -3002,9 +3002,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isUnParenthesizedAsyncArrowFunctionWorker(): Tristate {
|
||||
// AsyncArrowFunctionExpression:
|
||||
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
|
||||
if (token === SyntaxKind.AsyncKeyword) {
|
||||
nextToken();
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
// If the "async" is followed by "=>" token then it is not a begining of an async arrow-function
|
||||
// but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher"
|
||||
if (scanner.hasPrecedingLineBreak() || token === SyntaxKind.EqualsGreaterThanToken) {
|
||||
return Tristate.False;
|
||||
}
|
||||
// Check for un-parenthesized AsyncArrowFunction
|
||||
|
||||
Reference in New Issue
Block a user