Description
π Search Terms
const let block keyword if
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
This code issues a somewhat perplexing error
function f() {
if (1 > 0)
const e = 3;
console.log(e);
}
}
While there's also an error on the final }
, this can easily be off-screen, so it appears like TS has totally gone off the rails. We should issue the correct "const' declarations can only be declared inside a block" error more-unconditionally so that it's apparent that there's a syntax error earlier in the program (the missing {
after the if)
π Actual behavior
The error doesn't appear until all the other syntactic problems have been removed
π Expected behavior
It should always appear
Additional information about the issue
No response