Closed
Description
Try in the playground.
class Dog {
}
declare let x: Dog | string;
if (x instanceof Dog) {
x
}
else {
x.toLowerCase()
}
Expected: No error, first branch's x
has type Dog
, second branch's x
has type string
Actual: Property 'toLowerCase' does not exist on type 'never'. (first branch is string | Dog
, second is never
)
We should be accounting for primitives a little less sloppily. instanceof
checks don't work on primitive types.