File tree 1 file changed +26
-10
lines changed
1 file changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -2450,27 +2450,43 @@ namespace ts {
2450
2450
if ( token === SyntaxKind . LessThanToken ) {
2451
2451
return true ;
2452
2452
}
2453
-
2454
2453
return token === SyntaxKind . OpenParenToken && lookAhead ( isUnambiguouslyStartOfFunctionType ) ;
2455
2454
}
2456
2455
2456
+ function skipParameterStart ( ) : boolean {
2457
+ if ( isModifierKind ( token ) ) {
2458
+ // Skip modifiers
2459
+ parseModifiers ( ) ;
2460
+ }
2461
+ if ( isIdentifier ( ) ) {
2462
+ nextToken ( ) ;
2463
+ return true ;
2464
+ }
2465
+ if ( token === SyntaxKind . OpenBracketToken || token === SyntaxKind . OpenBraceToken ) {
2466
+ // Return true if we can parse an array or object binding pattern with no errors
2467
+ const count = parseDiagnostics . length ;
2468
+ parseIdentifierOrPattern ( ) ;
2469
+ return count === parseDiagnostics . length ;
2470
+ }
2471
+ return false ;
2472
+ }
2473
+
2457
2474
function isUnambiguouslyStartOfFunctionType ( ) {
2458
2475
nextToken ( ) ;
2459
2476
if ( token === SyntaxKind . CloseParenToken || token === SyntaxKind . DotDotDotToken ) {
2460
2477
// ( )
2461
2478
// ( ...
2462
2479
return true ;
2463
2480
}
2464
- if ( isIdentifier ( ) || isModifierKind ( token ) ) {
2465
- nextToken ( ) ;
2481
+ if ( skipParameterStart ( ) ) {
2482
+ // We successfully skipped modifiers (if any) and an identifier or binding pattern,
2483
+ // now see if we have something that indicates a parameter declaration
2466
2484
if ( token === SyntaxKind . ColonToken || token === SyntaxKind . CommaToken ||
2467
- token === SyntaxKind . QuestionToken || token === SyntaxKind . EqualsToken ||
2468
- isIdentifier ( ) || isModifierKind ( token ) ) {
2469
- // ( id :
2470
- // ( id ,
2471
- // ( id ?
2472
- // ( id =
2473
- // ( modifier id
2485
+ token === SyntaxKind . QuestionToken || token === SyntaxKind . EqualsToken ) {
2486
+ // ( xxx :
2487
+ // ( xxx ,
2488
+ // ( xxx ?
2489
+ // ( xxx =
2474
2490
return true ;
2475
2491
}
2476
2492
if ( token === SyntaxKind . CloseParenToken ) {
You can’t perform that action at this time.
0 commit comments