@@ -1468,14 +1468,14 @@ module ts {
1468
1468
1469
1469
// *Maybe* we had an arrow function and we need to try to parse it out,
1470
1470
// rolling back and trying other parses if we fail.
1471
- var sig = tryParse ( parseSignatureIfArrowOrBraceFollows ) ;
1472
- if ( sig === undefined ) {
1473
- return undefined ;
1474
- }
1475
- else {
1471
+ var sig = tryParseSignatureIfArrowOrBraceFollows ( ) ;
1472
+ if ( sig ) {
1476
1473
parseExpected ( SyntaxKind . EqualsGreaterThanToken ) ;
1477
1474
return parseArrowExpressionTail ( pos , sig , /*noIn:*/ false ) ;
1478
1475
}
1476
+ else {
1477
+ return undefined ;
1478
+ }
1479
1479
}
1480
1480
1481
1481
// True -> We definitely expect a parenthesized arrow function here.
@@ -1549,22 +1549,24 @@ module ts {
1549
1549
return Tristate . False ;
1550
1550
}
1551
1551
1552
-
10000
function parseSignatureIfArrowOrBraceFollows ( ) : ParsedSignature {
1553
- var sig = parseSignature ( SyntaxKind . CallSignature , SyntaxKind . ColonToken ) ;
1552
+ function tryParseSignatureIfArrowOrBraceFollows ( ) : ParsedSignature {
1553
+ return tryParse ( ( ) => {
1554
+ var sig = parseSignature ( SyntaxKind . CallSignature , SyntaxKind . ColonToken ) ;
1554
1555
1555
- // Parsing a signature isn't enough.
1556
- // Parenthesized arrow signatures often look like other valid expressions.
1557
- // For instance:
1558
- // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value.
1559
- // - "(x,y)" is a comma expression parsed as a signature with two parameters.
1560
- // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
1561
- //
1562
- // So we need just a bit of lookahead to ensure that it can only be a signature.
1563
- if ( token === SyntaxKind . EqualsGreaterThanToken || token === SyntaxKind . OpenBraceToken ) {
1564
- return sig ;
1565
- }
1556
+ // Parsing a signature isn't enough.
1557
+ // Parenthesized arrow signatures often look like other valid expressions.
1558
+ // For instance:
1559
+ // - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value.
1560
+ // - "(x,y)" is a comma expression parsed as a signature with two parameters.
1561
+ // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
1562
+ //
1563
+ // So we need just a bit of lookahead to ensure that it can only be a signature.
1564
+ if ( token === SyntaxKind . EqualsGreaterThanToken || token === SyntaxKind . OpenBraceToken ) {
1565
+ return sig ;
1566
+ }
1566
1567
1567
- return undefined ;
1568
+ return undefined ;
1569
+ } ) ;
1568
1570
}
1569
1571
1570
1572
function parseArrowExpressionTail ( pos : number , sig : ParsedSignature , noIn : boolean ) : FunctionExpression {
0 commit comments