Closed
Description
I'd like to use user-defined type guards in the following manner:
abstract class Animal
{
get isDog(): this is Dog;
}
class Dog extends Animal
{
get isDog(): this is Dog { return true; }
bark() { console.log("woof"); }
}
let animal = new Dog();
if (animal.isDog)
{
animal.bark()
}
This use-case was suggested by @RyanCavanaugh when he opened #1007 but seems to be unsupported as of TypeScript 1.6.