Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2999,9 +2999,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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [arrowFunctionWithParameterNameAsync.ts]

const x = async => async;

//// [arrowFunctionWithParameterNameAsync.js]
var x = function (async) { return async; };
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== tests/cases/conformance/async/es6/asyncArrowFunction/arrowFunctionWithParameterNameAsync.ts ===

const x = async => async;
>x : Symbol(x, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 5))
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 9))
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync.ts, 1, 9))

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/asyncArrowFunction/arrowFunctionWithParameterNameAsync.ts ===

const x = async => async;
>x : (async: any) => any
>async => async : (async: any) => any
>async : any
>async : any

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: ES5
// @noEmitHelpers: true

const x = async => async;