Closed
Description
TypeScript Version: nightly (2.0.0-dev.20160920)
TypeScript Command: tsc --target ES5 test.ts
Code (test.ts)
// This arrow shorthand will be properly transformed
let log = (t) => { console.log(t); };
// The arrow shorthand used in the for-loop won't be properly transformed
let items = [{ name: "A" }, { name: "C" }, { name: "B" }];
for (var item of items.sort((a, b) => a.name.localeCompare(b.name))) {
console.log(item);
}
becomes
var log = function (t) { console.log(t); };
var items = [{ name: "A" }, { name: "C" }, { name: "B" }];
for (var _i = 0, _a = items.sort((a, b) => a.name.localeCompare(b.name)); _i < _a.length; _i++) {
var item = _a[_i];
console.log(item);
}
Expected behavior:
When I target ES5 I don't expect any arrow shorthands to end up in the final JS.
Actual behavior:
You can see that the arrow shorthand after items.sort
is still there.