Nested else { if (...) }

Topics: Language Specification
Nov 9, 2012 at 8:22 PM

Is there a good reason that the TypeScript compiler outputs nested else blocks rather than "else if" blocks?

For example, this TypeScript:

if (a) {
}
else if (b) {
}

compiles to this JavaScript:

if (a) {
} else {
    if (b) {
    }
}
When there are many "else if" blocks, this becomes deeply nested and harder to read.

Coordinator
Nov 12, 2012 at 3:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.