Why this code doesn't result in an empty string after compilation with SIMPLE_OPTIMIZATIONS
/**
* @define {boolean}
*/
var TEST = false;
(function() {
if (TEST) {
foo();
}
})();
and instead I get the following?
var TEST=!1;(function(){TEST&&foo()})();
The if
is unreachable but the closure compiler doesn't remove the code.
With "advanced optimizations" the result is what I expect (empty) but "simple optimizations" give the above result. Why this difference? The code will never be executed in both cases.
EDIT:
If I remove the closure, the if
block is removed too. Why with closure this doesn't happen?