const foo = new Set;
foo.add("bar");
console.log(foo.size);
for (const val of foo) {
console.log(`of ${val}`);
}
for (const key of foo) {
console.log(`in ${key}`);
}
console.log(`entries ${foo.entries().next().value}`);
tsc is transpiling the above to
var foo = new Set;
foo.add("bar");
console.log(foo.size);
for (var _i = 0, foo_1 = foo; _i < foo_1.length; _i++) {
var val = foo_1[_i];
console.log("of ".concat(val));
}
for (var _a = 0, foo_2 = foo; _a < foo_2.length; _a++) {
var key = foo_2[_a];
console.log("in ".concat(key));
}
console.log("entries ".concat(foo.entries().next().value));
What could be causing this behavior? That use of numeric indexing looks completely invalid to me, and it results in zero iterations of both loops.
I confirmed this behavior persists with an empty or missing tsconfig.json