defs
Version:
Static scope analysis and transpilation of ES6 block scoped const and let variables, to ES3.
26 lines (22 loc) • 408 B
JavaScript
;
x; // error (unless disallowUnknownReferences=false)
if (true) {
x; // error
if (true) {
x; // error
}
if (true) {
let x;
x; // ok
}
let f = function() {
return x; // ok
};
f(); // ok from a static analysis standpoint but runtime error in ES6
let x = 3;
f(); // ok
x; // ok
if (true) {
x; // ok
}
}