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
classBar{constructor(){console.log(foo);// BUG: no error}}constbar=newBar();functionBar2(){console.log(foo);// BUG: no error}constbar2=newBar2();functionbar3(){console.log(foo);// BUG: no error}bar3();console.log(foo);// error is thrownconstfoo=2;
Expected behavior:
"Block-scoped variable 'foo' used before its declaration." error for the three cases mentioned in the code example.
I don't know if this is out of scope for TypeScript, but maybe flow analysis could catch very simple cases like this:
functionbar(){console.log(foo);}bar();constfoo=2;
Actual behavior:
No"Block-scoped variable 'foo' used before its declaration." error for the three cases mentioned in the code example.
The text was updated successfully, but these errors were encountered:
Correctly detecting this in all cases would require all function calls to trace out their call graphs, which would be pretty expensive relative to the number of bugs we'd actually detect.
I don't know how expensive it would be to detect some cases for some function calls? I actually stumbled over this when I re-ordered functions inside one file with no complex code.
Feel free to close this, if you think its too expensive anyway :)
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: Playground (2.3.4?)
Code
Expected behavior:
"Block-scoped variable 'foo' used before its declaration."
error for the three cases mentioned in the code example.I don't know if this is out of scope for TypeScript, but maybe flow analysis could catch very simple cases like this:
Actual behavior:
No
"Block-scoped variable 'foo' used before its declaration."
error for the three cases mentioned in the code example.The text was updated successfully, but these errors were encountered: