I have the following interface:
export interface FooInterface {
barAction(x: any) : void;
}
Then I'm implementing it:
class FooImplA implements FooInterface {
barAction(x: any) : void {};
}
class FooImplB implements FooInterface {
barAction(x: any) : void {};
}
class FooImplB implements FooInterface {
barAction(x: any) : void {};
}
Now I want an array of the types FooImplA and FooImplB (not the instances).
Obviously, this works:
let typeArray = [FooImplA, FooImplB];
But I want it strongly typed. The below is what I have in mind, which doesn't work:
let typeArray: Array< (typeof FooInterface) > = [FooImplA, FooImplB];
let typeArray:FooInterface[] = ...not what you want?= [new FooImplA(), new FooImplB()]export interface Type<T> extends Function { new (...args: any[]): T; }. That probably has certain limitations, though it might at least let you define the constructor arguments.