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
My guess is that we stop trying to track the way this was narrowed because you're in an arrow function. Being able to track this would be pretty difficult, but maybe we could say that we still narrow in function expressions/arrow functions.
If we see a const narrowed by typeof, that should be "sticky" even in function bodies.
This isn't true for let, e.g.
letx=Math.random()>0.5 ? 'hey' : 1;if(typeofx==='number'){// Unsafewindow.setImmediate(()=>x.toFixed());// Safe but not distinguishable from above[0].map(()=>x.toFixed());}x='oops';
but we can be sure the typeof a const cannot change.
mhegazy
added
Duplicate
An existing issue was already created
and removed
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
labels
Apr 28, 2016
nightly build
numbers can't mutate,
x
holds a number, also it is a constant, constant can't change its value, so ...The text was updated successfully, but these errors were encountered: