You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This complains that x = 5; is referencing x before its declaration. While technically true, this is not really a TDZ error. Though the access of x appears before its declaration in source code order, it's being executed after it, so the assignment will not throw a ReferenceError and is valid ES6 that will log 5
If it was bar(); let x; instead, then the error would be valid, since then the assignment would be invoked in x's TDZ.
But detecting this statically will require some brittle / expensive flow analysis, and it's not hard to reorder the code so it doesn't hit this, so maybe it's okay to leave it unfixed. The only real life scenario I can think of that would hit this problem is an existing codebase that prefers to put functions at the top of their respective scopes, that then starts migrating from var to let and const.
The text was updated successfully, but these errors were encountered:
This complains that
x = 5;
is referencing x before its declaration. While technically true, this is not really a TDZ error. Though the access of x appears before its declaration in source code order, it's being executed after it, so the assignment will not throw a ReferenceError and is valid ES6 that will log5
If it was
bar(); let x;
instead, then the error would be valid, since then the assignment would be invoked in x's TDZ.But detecting this statically will require some brittle / expensive flow analysis, and it's not hard to reorder the code so it doesn't hit this, so maybe it's okay to leave it unfixed. The only real life scenario I can think of that would hit this problem is an existing codebase that prefers to put
function
s at the top of their respective scopes, that then starts migrating from var to let and const.The text was updated successfully, but these errors were encountered: