Hi,
it seems the fix for #6877 missed destructuring assignments.
TypeScript Version:
master (f06423b)
Code
Running the following code in tsc or in the playground:
(function() {
"use strict";
for (let i = 0; i < 4; i++) {
(() => [i] = [i + 1])();
console.log(i);
}
})();
when targeting ES5 will be compiled to:
(function () {
"use strict";
var _loop_1 = function(i) {
(function () { return (_a = [i + 1], i = _a[0], _a); var _a; })();
console.log(i);
};
for (var i = 0; i < 4; i++) {
_loop_1(i);
}
})();
Actual behavior when running the compiled snipped:
Expected behavior (running the original snipped in Firefox or Chrome):
Expected compilation result:
(function () {
"use strict";
var _loop_1 = function(i) {
(function () { return (_a = [i + 1], i = _a[0], _a); var _a; })();
console.log(i);
out_i_1 = i;
};
var out_i_1;
for (var i = 0; i < 4; i++) {
_loop_1(i);
i = out_i_1;
}
})();
Note that the same problem exists for object desctructuring.
Thanks!
Hi,
it seems the fix for #6877 missed destructuring assignments.
TypeScript Version:
master (f06423b)
Code
Running the following code in tsc or in the playground:
when targeting ES5 will be compiled to:
Actual behavior when running the compiled snipped:
Expected behavior (running the original snipped in Firefox or Chrome):
Expected compilation result:
Note that the same problem exists for object desctructuring.
Thanks!