It's because you are missing a semicolon.
This :
var i4 = function() {
console.log("I4 output")
return i = 4
}
(a > 3)
is executed like this :
var i4 = function() {
console.log("I4 output")
return i = 4
}(a > 3) // <--- You are executing i4, passing it "a > 3" as argument
Sidenote : Javascript allows you to do this, leading to a bug; but Typescript complains. It says that you are calling a function with 1 argument, when it expects 0. Typescript really is some improvement over JS and taught me a lot about it.
If you add a semicolon, the function is defined, but not executed :
var a = 4;
var i = 0;
var i3 = function() {
console.log("I3 output")
return i = i + 3
};
var i4 = function() {
console.log("I4 output")
return i = 4
}; // <-- Add semicolon
(a > 3) && i3() || (a < 5) && i4();
console.log(i)