From 858cca5a38c1d9b3ea32592a00b57bb853e789cf Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Mon, 18 Mar 2019 17:11:02 +0100 Subject: [PATCH] Fix arrow function body parsing precedence (#546) --- src/parser.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index aa0e3741..572984e9 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -1437,9 +1437,14 @@ export class Parser extends DiagnosticEmitter { tn.range(signatureStart, tn.pos) ); - var body: Statement | null; + var body: Statement | null = null; if (arrowKind) { - body = this.parseStatement(tn, false); + if (tn.skip(Token.OPENBRACE)) { + body = this.parseBlockStatement(tn, false); + } else { + let bodyExpression = this.parseExpression(tn, Precedence.COMMA + 1); + if (bodyExpression) body = Node.createExpressionStatement(bodyExpression); + } } else { if (!tn.skip(Token.OPENBRACE)) { this.error(