@@ -1335,29 +1335,29 @@ namespace ts {
1335
1335
return inContext ( NodeFlags . AwaitContext ) ;
1336
1336
}
1337
1337
1338
- function parseErrorAtCurrentToken ( message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | false {
1338
+ function parseErrorAtCurrentToken ( message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | undefined {
1339
1339
return parseErrorAt ( scanner . getTokenPos ( ) , scanner . getTextPos ( ) , message , arg0 ) ;
1340
1340
}
1341
1341
1342
- function parseErrorAtPosition ( start : number , length : number , message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | false {
1342
+ function parseErrorAtPosition ( start : number , length : number , message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | undefined {
1343
1343
// Don't report another error if it would just be at the same position as the last error.
1344
1344
const lastError = lastOrUndefined ( parseDiagnostics ) ;
1345
- let result : DiagnosticWithDetachedLocation | false ;
1345
+ let result : DiagnosticWithDetachedLocation | undefined ;
1346
1346
if ( ! lastError || start !== lastError . start ) {
1347
- result = createDetachedDiagnostic ( fileName , start , length , message , arg0 )
1347
+ result = createDetachedDiagnostic ( fileName , start , length , message , arg0 ) ;
1348
1348
parseDiagnostics . push ( result ) ;
1349
1349
}
1350
1350
else {
1351
- result = false ;
1351
+ result = undefined ;
1352
1352
}
1353
1353
1354
1354
// Mark that we've encountered an error. We'll set an appropriate bit on the next
1355
1355
// node we finish so that it can't be reused incrementally.
1356
1356
parseErrorBeforeNextFinishedNode = true ;
1357
- return result
1357
+ return result ;
1358
1358
}
1359
1359
1360
- function parseErrorAt ( start : number , end : number , message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | false {
1360
+ function parseErrorAt ( start : number , end : number , message : DiagnosticMessage , arg0 ?: any ) : DiagnosticWithDetachedLocation | undefined {
1361
1361
return parseErrorAtPosition ( start , end - start , message , arg0 ) ;
1362
1362
}
1363
1363
@@ -1539,24 +1539,6 @@ namespace ts {
1539
1539
return false ;
1540
1540
}
1541
1541
1542
- /** Like parseExpected, but returns true=succeed, diagnostic=fail, false=fail+failed to log error */
1543
- function parseTokenForError ( kind : SyntaxKind , diagnosticMessage ?: DiagnosticMessage , shouldAdvance = true ) : DiagnosticWithDetachedLocation | boolean {
1544
- if ( token ( ) === kind ) {
1545
- if ( shouldAdvance ) {
1546
- nextToken ( ) ;
1547
- }
1548
- return true ;
1549
- }
1550
-
1551
- // Report specific message if provided with one. Otherwise, report generic fallback message.
1552
- if ( diagnosticMessage ) {
1553
- return parseErrorAtCurrentToken ( diagnosticMessage ) ;
1554
- }
1555
- else {
1556
- return parseErrorAtCurrentToken ( Diagnostics . _0_expected , tokenToString ( kind ) ) ;
1557
- }
1558
- }
1559
-
1560
1542
function parseExpectedJSDoc ( kind : JSDocSyntaxKind ) {
1561
1543
if ( token ( ) === kind ) {
1562
1544
nextTokenJSDoc ( ) ;
@@ -1567,16 +1549,18 @@ namespace ts {
1567
1549
}
1568
1550
1569
1551
function parseExpectedMatchingBrackets ( openKind : SyntaxKind , closeKind : SyntaxKind , openPosition : number ) {
1570
- const lastError = parseTokenForError ( closeKind ) ;
1571
- if ( typeof lastError === 'boolean' )
1572
- return lastError
1573
- else {
1552
+ if ( token ( ) === closeKind ) {
1553
+ nextToken ( ) ;
1554
+ return true ;
1555
+ }
1556
+ const lastError = parseErrorAtCurrentToken ( Diagnostics . _0_expected , tokenToString ( closeKind ) ) ;
1557
+ if ( lastError ) {
1574
1558
addRelatedInfo (
1575
1559
lastError ,
1576
1560
createDetachedDiagnostic ( fileName , openPosition , 1 , Diagnostics . The_parser_expected_to_find_a_1_to_match_the_0_token_here , tokenToString ( openKind ) , tokenToString ( closeKind ) )
1577
1561
) ;
1578
- return false ;
1579
1562
}
1563
+ return false ;
1580
1564
}
1581
1565
1582
1566
function parseOptional ( t : SyntaxKind ) : boolean {
0 commit comments