Narrowing switch(true) doesnt work for default case and is wrong for fallthrough cases in 5.3 #55986
Labels
Bug
A bug in TypeScript
Effort: Moderate
Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
Fix Available
A PR has been opened for this issue
Help Wanted
You can do this
Milestone
π Search Terms
switch, fallthrough
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.3.0-dev.20231004#code/C4TwDgpgBAZg9nKBeKByAhqqAfNAjLXVAY1QCgzi4A7AZ2FmTUynVtgQtoHcBLYYgAsAFMABOAVwgBKKAG8yUJVGJtoMZEhQZUALkXLVtdZu0F9ywzVpwANhAB0tuAHNhMaQcsB6b5f9QAHoA-F7KeGIQ6ADWYQAmEDDoErbAFv5UdHaOzm4eYUq+AZYhZAC+QA
π» Code
π Actual behavior
The fallthrough case has wrong type
b
.The default case is not narrowed.
π Expected behavior
In the fallthrough the type should be a union of
a | b
.The default case should be
c
.Additional information about the issue
Related to 70b7de1
The text was updated successfully, but these errors were encountered: