@@ -912,7 +912,7 @@ namespace ts {
912912 // Note: it is not actually necessary to save/restore the context flags here. That's
913913 // because the saving/restoring of these flags happens naturally through the recursive
914914 // descent nature of our parser. However, we still store this here just so we can
915- // assert that that invariant holds.
915+ // assert that invariant holds.
916916 const saveContextFlags = contextFlags ;
917917
918918 // If we're only looking ahead, then tell the scanner to only lookahead as well.
@@ -2339,6 +2339,7 @@ namespace ts {
23392339 token ( ) === SyntaxKind . LessThanToken ||
23402340 token ( ) === SyntaxKind . QuestionToken ||
23412341 token ( ) === SyntaxKind . ColonToken ||
2342+ token ( ) === SyntaxKind . CommaToken ||
23422343 canParseSemicolon ( ) ;
23432344 }
23442345 return false ;
@@ -2765,7 +2766,7 @@ namespace ts {
27652766 // Note: for ease of implementation we treat productions '2' and '3' as the same thing.
27662767 // (i.e. they're both BinaryExpressions with an assignment operator in it).
27672768
2768- // First, do the simple check if we have a YieldExpression (production '5 ').
2769+ // First, do the simple check if we have a YieldExpression (production '6 ').
27692770 if ( isYieldExpression ( ) ) {
27702771 return parseYieldExpression ( ) ;
27712772 }
@@ -3373,24 +3374,40 @@ namespace ts {
33733374 }
33743375
33753376 /**
3376- * Parse ES7 unary expression and await expression
3377+ * Parse ES7 exponential expression and await expression
3378+ *
3379+ * ES7 ExponentiationExpression:
3380+ * 1) UnaryExpression[?Yield]
3381+ * 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
33773382 *
3378- * ES7 UnaryExpression:
3379- * 1) SimpleUnaryExpression[?yield]
3380- * 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
33813383 */
33823384 function parseUnaryExpressionOrHigher ( ) : UnaryExpression | BinaryExpression {
3383- if ( isAwaitExpression ( ) ) {
3384- return parseAwaitExpression ( ) ;
3385- }
3386-
3387- if ( isIncrementExpression ( ) ) {
3385+ /**
3386+ * ES7 UpdateExpression:
3387+ * 1) LeftHandSideExpression[?Yield]
3388+ * 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
3389+ * 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
3390+ * 4) ++UnaryExpression[?Yield]
3391+ * 5) --UnaryExpression[?Yield]
3392+ */
3393+ if ( isUpdateExpression ( ) ) {
33883394 const incrementExpression = parseIncrementExpression ( ) ;
33893395 return token ( ) === SyntaxKind . AsteriskAsteriskToken ?
33903396 < BinaryExpression > parseBinaryExpressionRest ( getBinaryOperatorPrecedence ( ) , incrementExpression ) :
33913397 incrementExpression ;
33923398 }
33933399
3400+ /**
3401+ * ES7 UnaryExpression:
3402+ * 1) UpdateExpression[?yield]
3403+ * 2) delete UpdateExpression[?yield]
3404+ * 3) void UpdateExpression[?yield]
3405+ * 4) typeof UpdateExpression[?yield]
3406+ * 5) + UpdateExpression[?yield]
3407+ * 6) - UpdateExpression[?yield]
3408+ * 7) ~ UpdateExpression[?yield]
3409+ * 8) ! UpdateExpression[?yield]
3410+ */
33943411 const unaryOperator = token ( ) ;
33953412 const simpleUnaryExpression = parseSimpleUnaryExpression ( ) ;
33963413 if ( token ( ) === SyntaxKind . AsteriskAsteriskToken ) {
@@ -3408,8 +3425,8 @@ namespace ts {
34083425 /**
34093426 * Parse ES7 simple-unary expression or higher:
34103427 *
3411- * ES7 SimpleUnaryExpression :
3412- * 1) IncrementExpression [?yield]
3428+ * ES7 UnaryExpression :
3429+ * 1) UpdateExpression [?yield]
34133430 * 2) delete UnaryExpression[?yield]
34143431 * 3) void UnaryExpression[?yield]
34153432 * 4) typeof UnaryExpression[?yield]
@@ -3432,13 +3449,15 @@ namespace ts {
34323449 return parseTypeOfExpression ( ) ;
34333450 case SyntaxKind . VoidKeyword :
34343451 return parseVoidExpression ( ) ;
3435- case SyntaxKind . AwaitKeyword :
3436- return parseAwaitExpression ( ) ;
34373452 case SyntaxKind . LessThanToken :
34383453 // This is modified UnaryExpression grammar in TypeScript
34393454 // UnaryExpression (modified):
34403455 // < type > UnaryExpression
34413456 return parseTypeAssertion ( ) ;
3457+ case SyntaxKind . AwaitKeyword :
3458+ if ( isAwaitExpression ( ) ) {
3459+ return parseAwaitExpression ( ) ;
3460+ }
34423461 default :
34433462 return parseIncrementExpression ( ) ;
34443463 }
@@ -3447,14 +3466,14 @@ namespace ts {
34473466 /**
34483467 * Check if the current token can possibly be an ES7 increment expression.
34493468 *
3450- * ES7 IncrementExpression :
3469+ * ES7 UpdateExpression :
34513470 * LeftHandSideExpression[?Yield]
34523471 * LeftHandSideExpression[?Yield][no LineTerminator here]++
34533472 * LeftHandSideExpression[?Yield][no LineTerminator here]--
34543473 * ++LeftHandSideExpression[?Yield]
34553474 * --LeftHandSideExpression[?Yield]
34563475 */
3457- function isIncrementExpression ( ) : boolean {
3476+ function isUpdateExpression ( ) : boolean {
34583477 // This function is called inside parseUnaryExpression to decide
34593478 // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
34603479 switch ( token ( ) ) {
@@ -3465,6 +3484,7 @@ namespace ts {
34653484 case SyntaxKind . DeleteKeyword :
34663485 case SyntaxKind . TypeOfKeyword :
34673486 case SyntaxKind . VoidKeyword :
3487+ case SyntaxKind . AwaitKeyword :
34683488 return false ;
34693489 case SyntaxKind . LessThanToken :
34703490 // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression
@@ -5893,6 +5913,9 @@ namespace ts {
58935913 case SyntaxKind . BooleanKeyword :
58945914 case SyntaxKind . SymbolKeyword :
58955915 case SyntaxKind . VoidKeyword :
5916+ case SyntaxKind . NullKeyword :
5917+ case SyntaxKind . UndefinedKeyword :
5918+ case SyntaxKind . NeverKeyword :
58965919 return parseTokenNode < JSDocType > ( ) ;
58975920 case SyntaxKind . StringLiteral :
58985921 case SyntaxKind . NumericLiteral :
0 commit comments