-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
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
sstchurmsft and gabritto
Metadata
Metadata
Assignees
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases