Open
Description
TypeScript Version: 2.3.1
Code
class FooTask {
foo: number;
}
class BarTask {
bar: number;
}
type taskType = FooTask|BarTask;
function createEvent(task: taskType) {
if (task instanceof FooTask) {
task.foo; // Works.
}
switch (task.constructor) {
case FooTask:
task.foo; // Fails.
}
}
It would be nice if the second worked like the first; narrowed the type of task
appropriately.