@@ -7505,7 +7505,11 @@ namespace Parser {
75057505 case SyntaxKind.LetKeyword:
75067506 case SyntaxKind.ConstKeyword:
75077507 case SyntaxKind.UsingKeyword:
7508+ return parseVariableStatement(pos, hasJSDoc, modifiersIn);
75087509 case SyntaxKind.AwaitKeyword:
7510+ if (!isAwaitUsingDeclaration()) {
7511+ break;
7512+ }
75097513 return parseVariableStatement(pos, hasJSDoc, modifiersIn);
75107514 case SyntaxKind.FunctionKeyword:
75117515 return parseFunctionDeclaration(pos, hasJSDoc, modifiersIn);
@@ -7534,17 +7538,16 @@ namespace Parser {
75347538 default:
75357539 return parseExportDeclaration(pos, hasJSDoc, modifiersIn);
75367540 }
7537- default:
7538- if (modifiersIn) {
7539- // We reached this point because we encountered decorators and/or modifiers and assumed a declaration
7540- // would follow. For recovery and error reporting purposes, return an incomplete declaration.
7541- const missing = createMissingNode<MissingDeclaration>(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
7542- setTextRangePos(missing, pos);
7543- (missing as Mutable<MissingDeclaration>).modifiers = modifiersIn;
7544- return missing;
7545- }
7546- return undefined!; // TODO: GH#18217
75477541 }
7542+ if (modifiersIn) {
7543+ // We reached this point because we encountered decorators and/or modifiers and assumed a declaration
7544+ // would follow. For recovery and error reporting purposes, return an incomplete declaration.
7545+ const missing = createMissingNode<MissingDeclaration>(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
7546+ setTextRangePos(missing, pos);
7547+ (missing as Mutable<MissingDeclaration>).modifiers = modifiersIn;
7548+ return missing;
7549+ }
7550+ return undefined!; // TODO: GH#18217
75487551 }
75497552
75507553 function nextTokenIsStringLiteral() {
@@ -7677,7 +7680,9 @@ namespace Parser {
76777680 flags |= NodeFlags.Using;
76787681 break;
76797682 case SyntaxKind.AwaitKeyword:
7680- Debug.assert(isAwaitUsingDeclaration());
7683+ if (!isAwaitUsingDeclaration()) {
7684+ break;
7685+ }
76817686 flags |= NodeFlags.AwaitUsing;
76827687 nextToken();
76837688 break;
0 commit comments