Closed
Description
TypeScript Version:
nightly (1.9.0-dev.20160619-1.0)
Code
interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}
interface Circle {
kind: "circle";
radius: number;
}
type Shape = Rectangle | Circle;
function test1(s: Shape) {
if (s.kind === "rectangle") {
s; // Rectangle
setTimeout(() => {
s; // Rectangle | Circle
});
}
}
Expected behavior: both s
usages to narrow to type Rectangle
Actual behavior: the s
in the nested function scope has type Rectangle | Circle