File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -3695,7 +3695,7 @@ namespace ts {
3695
3695
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
3696
3696
//
3697
3697
// So we need just a bit of lookahead to ensure that it can only be a signature.
3698
- if ( ! allowAmbiguity && token ( ) !== SyntaxKind . EqualsGreaterThanToken && token ( ) !== SyntaxKind . OpenBraceToken ) {
3698
+ if ( ! allowAmbiguity && token ( ) !== SyntaxKind . EqualsGreaterThanToken && ( contextFlags & NodeFlags . InConditionalWhenTrue || token ( ) !== SyntaxKind . OpenBraceToken ) ) {
3699
3699
// Returning undefined here will cause our caller to rewind to where we started from.
3700
3700
return undefined ;
3701
3701
}
@@ -3747,7 +3747,9 @@ namespace ts {
3747
3747
const node = < ConditionalExpression > createNode ( SyntaxKind . ConditionalExpression , leftOperand . pos ) ;
3748
3748
node . condition = leftOperand ;
3749
3749
node . questionToken = questionToken ;
3750
- node . whenTrue = doOutsideOfContext ( disallowInAndDecoratorContext , parseAssignmentExpressionOrHigher ) ;
3750
+ node . whenTrue = doInsideOfContext (
3751
+ NodeFlags . InConditionalWhenTrue ,
3752
+ ( ) => doOutsideOfContext ( disallowInAndDecoratorContext , parseAssignmentExpressionOrHigher ) ) ;
3751
3753
node . colonToken = parseExpectedToken ( SyntaxKind . ColonToken ) ;
3752
3754
node . whenFalse = nodeIsPresent ( node . colonToken )
3753
3755
? parseAssignmentExpressionOrHigher ( )
Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ namespace ts {
553
553
/* @internal */ Ambient = 1 << 22 , // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier.
554
554
/* @internal */ InWithStatement = 1 << 23 , // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
555
555
JsonFile = 1 << 24 , // If node was parsed in a Json
556
+ /* @internal */ InConditionalWhenTrue = 1 << 25 , // If node was parsed in the true side of a ConditionalExpression
556
557
557
558
BlockScoped = Let | Const ,
558
559
You can’t perform that action at this time.
0 commit comments