I'm trying to discover a pattern for combining multiple interfaces into one abstract class. Presently I can combine multiple interfaces via implements
, but an interface cannot declare a constructor. When I must introduce a constructor I'm forced to use an abstract class. When I use a abstract class I must re-declare the entire composite interface! Surely I'm missing something?
interface ILayerInfo {
a: string;
}
interface ILayerStatic {
b(): string;
}
class Layer implements ILayerInfo, ILayerStatic {
constructor(info: ILayerInfo);
a: string;
b(): string;
}
ANSWER: Use new
:
interface Layer extends ILayerInfo, ILayerStatic {
new(info: ILayerInfo);
}
// usage: new Layer({ a: "" });