Closed
Description
TypeScript Version: 4.2.0-dev.20201127
Search Terms: switch, narrow, constructor
Code
function foo(o: any) {
switch (o.constructor) {
case Array: {
o // o: any
}
}
}
function bar(o: any) {
if (o.constructor === Array) {
o // o: any[]
}
}
Expected behavior: Both functions narrow the value to any[]
Actual behavior: Switch fails to narrow value
Playground Link: playground
Related Issues: #2214 (comment), #32774