From 8675dc142f78c784663e814dd4b57afe8669b428 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:53:32 -0700 Subject: [PATCH] Inherit allowReturnTypeInArrowFunction in parseConditionalExpressionRest --- src/compiler/parser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f1419f2770af4..8c16ff9a910da 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4422,7 +4422,7 @@ namespace ts { } // It wasn't an assignment or a lambda. This is a conditional expression: - return parseConditionalExpressionRest(expr, pos); + return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression(): boolean { @@ -4853,7 +4853,7 @@ namespace ts { return node; } - function parseConditionalExpressionRest(leftOperand: Expression, pos: number): Expression { + function parseConditionalExpressionRest(leftOperand: Expression, pos: number, allowReturnTypeInArrowFunction: boolean): Expression { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (!questionToken) { @@ -4870,7 +4870,7 @@ namespace ts { doOutsideOfContext(disallowInAndDecoratorContext, () => parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false)), colonToken = parseExpectedToken(SyntaxKind.ColonToken), nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false) + ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) : createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)) ), pos