andrei-markeev/ts2c

Prefix increment operator not working in for loops

Closed this issue · 1 comments

Some of us use 2-statement style for loops using the prefix increment operator. These don't seem to compile, although in COVERAGE.md it says that prefix increment operators are implemented. Example:

var x: number[] = [];
for (var i = -1; ++i < x.length;)
{
  console.log(i);
}

(Side note: This is a very interesting project. Years ago I posted this on the TypeScript forum and have been following many TypeScript => !JavaScript compiler projects.)

Hi, the actual reason was empty increment part of the for loop. Now fixed and your example compiles fine.

Years ago I posted this on the TypeScript forum

Yeah I saw this post and it was actually part of inspiration to create this project, all those super-experts telling that it is not possible 😃 Still convinced that everything can be transpiled except eval and new Function.

Also as a side note, I do need to spend couple of hours and add proper error handling to the live demo thing. Currently if transpilation fails, it throws error into console but there's no user-friendly feedback. And if some features aren't supported, this information is added to the code in comments, but if output is big enough, it's hard to spot those - this also needs addressing.