@@ -3693,9 +3693,11 @@ namespace ts {
3693
3693
// - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value.
3694
3694
// - "(x,y)" is a comma expression parsed as a signature with two parameters.
3695
3695
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
3696
+ // - "a ? (b): function() {}" will too, since function() is a valid JSDoc function type.
3696
3697
//
3697
3698
// So we need just a bit of lookahead to ensure that it can only be a signature.
3698
- if ( ! allowAmbiguity && token ( ) !== SyntaxKind . EqualsGreaterThanToken && ( contextFlags & NodeFlags . InConditionalWhenTrue || token ( ) !== SyntaxKind . OpenBraceToken ) ) {
3699
+ const hasJSDocFunctionType = node . type && isJSDocFunctionType ( node . type ) ;
3700
+ if ( ! allowAmbiguity && token ( ) !== SyntaxKind . EqualsGreaterThanToken && ( hasJSDocFunctionType || token ( ) !== SyntaxKind . OpenBraceToken ) ) {
3699
3701
// Returning undefined here will cause our caller to rewind to where we started from.
3700
3702
return undefined ;
3701
3703
}
@@ -3747,9 +3749,7 @@ namespace ts {
3747
3749
const node = < ConditionalExpression > createNode ( SyntaxKind . ConditionalExpression , leftOperand . pos ) ;
3748
3750
node . condition = leftOperand ;
3749
3751
node . questionToken = questionToken ;
3750
- node . whenTrue = doInsideOfContext (
3751
- NodeFlags . InConditionalWhenTrue ,
3752
- ( ) => doOutsideOfContext ( disallowInAndDecoratorContext , parseAssignmentExpressionOrHigher ) ) ;
3752
+ node . whenTrue = doOutsideOfContext ( disallowInAndDecoratorContext , parseAssignmentExpressionOrHigher ) ;
3753
3753
node . colonToken = parseExpectedToken ( SyntaxKind . ColonToken ) ;
3754
3754
node . whenFalse = nodeIsPresent ( node . colonToken )
3755
3755
? parseAssignmentExpressionOrHigher ( )
0 commit comments