-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
class Base { }
class Derived1 extends Base { }
class Derived2 extends Base { }
var t1 = (Math.random() < 0.5) ? "asdasd" : 34;
// t1: string | number
var t2 = (Math.random() < 0.5) ? new Derived1() : new Derived2();
// t2: Derived1
Expected behavior:
// t2: Derived1 | Derived2
I understand the shapes are the same, but this means the runtime types don't match up with the static type.
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug