With Polymorphic this in TypeScript 1.7, as I discovered here, we can define a method in a class with a return type of this, and automatically, any classes that
What are you expecting this static method to return in the inherited subclass? Is it something like this:
class A {
private static _instances = new Array();
static instances(): A[] { return A._instances; }
constructor() { A._instances.push(this); }
}
class B extends A {
static instances(): B[] {
return (A.instances().filter(i => i instanceof B));
}
constructor() { super(); };
}
var a = new A();
var b = new B();
console.log(
"A count: " + A.instances().length +
" B count: " + B.instances().length);
This will output "A count: 2 B count: 1". Or what are you expecting?