Closed theKashey closed 2 months ago
Ouch! Thanks for finding this edge case. I guess I've never seen in our projects thanks to no-shadow
being enforced.
It was never seen around because we usually transpile everything down to var
. Which is not a bad idea, by removing TDZ you make some things faster.
unction token(path, fallback) {
var [_tokens] = (0, _reactMagneticDi.di)([_tokenNames.default], token);
var token = _tokens[path];
}
in this case, it would not be an error, but token
will be undefined as it still placed before initialization.
CI builds may be green, but tests on local fail. @albertogasparin - can you verify how the current solution works for you and on your machine 🙏
After running npm i
the test passes in local too. Must be some Babel package update. Might do a global bump soon
🤔 npm
, not yarn
Consider the following code:
right now it will be converted into
However, due to
let token
we will face the temporal dead zone or "cannot access token before initialization"This PR just handles this moment by removing scope when such case is detected.