Open fengzilong opened 2 years ago
Describe the bug
As described in title
To Reproduce
Minimal code to reproduce the bug
function foo() { if ( true ) { return } const timer = setInterval( () => { console.log( timer ) }, 1000 ) }
Actual Output
there is no Error thrown
function foo() { var timer = setInterval(function () { console.log(timer); }, 1000); }
Expected Output
function foo() {}
Possible solution
If the timer reference doesn't appeared before return in current scope, it can be safely removed
timer
return
Additional context
Here is the Babel REPL link to reproduce
Describe the bug
As described in title
To Reproduce
Minimal code to reproduce the bug
Actual Output
there is no Error thrown
Expected Output
Possible solution
If the
timer
reference doesn't appeared beforereturn
in current scope, it can be safely removedAdditional context
Here is the Babel REPL link to reproduce