Incorrect hover shown for union variable in while
loop following an exhaustive switch
#47538
Labels
Bug
A bug in TypeScript
Domain: Quick Info
e.g. hover text, tool-tips, and tooltips.
Help Wanted
You can do this
Milestone
Bug Report
π Search Terms
while switch union narrowing never
π Version & Regression Information
Version: 4.5.4
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
On the line
} else if (foo === "bbb") {
when you hover overfoo
typescript thinks the type is never. If that was the case then you'd expect nothing inside that block to run.π Expected behavior
foo
should be type"bbb"
here, and if you remove the switch statement it is. Furthermore if you run the compiled JS, it does hit all the console.log lines and producesThe text was updated successfully, but these errors were encountered: