Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/transformers/es2015.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,7 @@ namespace ts {
addRange(statements, convertedLoopBodyStatements);
}
else {
const statement = visitNode(node.statement, visitor, isStatement);
const statement = visitNode(node.statement, visitor, isStatement, /*optional*/ false, liftToBlock);
if (isBlock(statement)) {
addRange(statements, statement.statements);
bodyLocation = statement;
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [nestedLoopWithOnlyInnerLetCaptured.ts]
declare let doSomething;

for (let a1 of [])
for (let a2 of a1.someArray)
doSomething(() => a2);

//// [nestedLoopWithOnlyInnerLetCaptured.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var a1 = _a[_i];
var _loop_1 = function (a2) {
doSomething(function () { return a2; });
};
for (var _b = 0, _c = a1.someArray; _b < _c.length; _b++) {
var a2 = _c[_b];
_loop_1(a2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts ===
declare let doSomething;
>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11))

for (let a1 of [])
>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8))

for (let a2 of a1.someArray)
>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12))
>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8))

doSomething(() => a2);
>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11))
>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12))

20 changes: 20 additions & 0 deletions tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts ===
declare let doSomething;
>doSomething : any

for (let a1 of [])
>a1 : any
>[] : undefined[]

for (let a2 of a1.someArray)
>a2 : any
>a1.someArray : any
>a1 : any
>someArray : any

doSomething(() => a2);
>doSomething(() => a2) : any
>doSomething : any
>() => a2 : () => any
>a2 : any

6 changes: 6 additions & 0 deletions tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @target: es5
declare let doSomething;

for (let a1 of [])
for (let a2 of a1.someArray)
doSomething(() => a2);