Given this class hierarhcy
export class A {
static m() { return 'a'};
}
export class B extends A {
static m() { return 'b'};
}
export class C extends A {
static m() { return 'c'};
}
I need a method taking an array of classes (not instance) extending A and calls m() on each element of the array:
function looper(classes: A[]) {
classes.forEach(c => c.m());
}
This expects an array of instances of A or its subclasses.
How can I have a method that takes as argument classes that extend A?
Generics as pointed out by @Oscar Paz
EDIT 1
Moreover the input to looper needs to be stored in a property of an object:
export class Container {
public klazzes: A[];
}

