diff --git a/javascript/typescript/TypeScriptParser.g4 b/javascript/typescript/TypeScriptParser.g4 index a58aaefb29..68a9a564e4 100644 --- a/javascript/typescript/TypeScriptParser.g4 +++ b/javascript/typescript/TypeScriptParser.g4 @@ -476,8 +476,10 @@ iterationStatement | While '(' expressionSequence ')' statement # WhileStatement | For '(' expressionSequence? SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForStatement | For '(' varModifier variableDeclarationList SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForInStatement - | For '(' varModifier variableDeclaration (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForVarInStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' varModifier variableDeclaration In expressionSequence ')' statement # ForVarInStatement + | For Await? '(' singleExpression Identifier {this.p("of")}? expressionSequence ')' statement # ForOfStatement + | For Await? '(' varModifier variableDeclaration Identifier {this.p("of")}? expressionSequence ')' statement # ForVarOfStatement ; varModifier diff --git a/javascript/typescript/examples/Loop.ts b/javascript/typescript/examples/Loop.ts new file mode 100644 index 0000000000..971b1ab635 --- /dev/null +++ b/javascript/typescript/examples/Loop.ts @@ -0,0 +1,18 @@ +let object = {}; +for (let field in object) { +}; + +let array = []; +for (let element of array) { +}; + +for (let element: number of array) { +}; + +for await (const document of array) { + +}; + +for await (const document: string of array) { + +}; \ No newline at end of file