@@ -1865,9 +1865,12 @@ namespace ts {
1865
1865
let commaStart = - 1 ; // Meaning the previous token was not a comma
1866
1866
while ( true ) {
1867
1867
if ( isListElement ( kind , /*inErrorRecovery*/ false ) ) {
1868
+ const startPos = scanner . getStartPos ( ) ;
1868
1869
result . push ( parseListElement ( kind , parseElement ) ) ;
1869
1870
commaStart = scanner . getTokenPos ( ) ;
1871
+
1870
1872
if ( parseOptional ( SyntaxKind . CommaToken ) ) {
1873
+ // No need to check for a zero length node since we know we parsed a comma
1871
1874
continue ;
1872
1875
}
1873
1876
@@ -1888,6 +1891,13 @@ namespace ts {
1888
1891
if ( considerSemicolonAsDelimiter && token ( ) === SyntaxKind . SemicolonToken && ! scanner . hasPrecedingLineBreak ( ) ) {
1889
1892
nextToken ( ) ;
1890
1893
}
1894
+ if ( startPos === scanner . getStartPos ( ) ) {
1895
+ // What we're parsing isn't actually remotely recognizable as a element and we've consumed no tokens whatsoever
1896
+ // Consume a token to advance the parser in some way and avoid an infinite loop
1897
+ // This can happen when we're speculatively parsing parenthesized expressions which we think may be arrow functions,
1898
+ // or when a modifier keyword which is disallowed as a parameter name (ie, `static` in strict mode) is supplied
1899
+ nextToken ( ) ;
1900
+ }
1891
1901
continue ;
1892
1902
}
1893
1903
@@ -2221,7 +2231,6 @@ namespace ts {
2221
2231
return finishNode ( node ) ;
2222
2232
}
2223
2233
2224
- const startPos = scanner . getStartPos ( ) ;
2225
2234
node . decorators = parseDecorators ( ) ;
2226
2235
node . modifiers = parseModifiers ( ) ;
2227
2236
node . dotDotDotToken = parseOptionalToken ( SyntaxKind . DotDotDotToken ) ;
@@ -2245,14 +2254,6 @@ namespace ts {
2245
2254
node . type = parseParameterType ( ) ;
2246
2255
node . initializer = parseBindingElementInitializer ( /*inParameter*/ true ) ;
2247
2256
2248
- if ( startPos === scanner . getStartPos ( ) ) {
2249
- // What we're parsing isn't actually remotely recognizable as a parameter and we've consumed no tokens whatsoever
2250
- // Consume a token to advance the parser in some way and avoid an infinite loop in `parseDelimitedList`
2251
- // This can happen when we're speculatively parsing parenthesized expressions which we think may be arrow functions,
2252
- // or when a modifier keyword which is disallowed as a parameter name (ie, `static` in strict mode) is supplied
2253
- nextToken ( ) ;
2254
- }
2255
-
2256
2257
return addJSDocComment ( finishNode ( node ) ) ;
2257
2258
}
2258
2259
0 commit comments