/**
 * Factory Method is a creational design pattern that provides
 * an interface for creating objects in a superclass, but allows
 * subclasses to alter the type of objects that will be created.
 */ abstract class Creator { public abstract factoryMethod ( ) ; public operation ( ) { const product = this . factoryMethod ( ) ; return product . operation ( ) ; } } export class ConcreteCreatorA extends Creator { public factoryMethod ( ) { return new ConcreteProductA ( ) ; } } export class ConcreteCreatorB extends Creator { public factoryMethod ( ) { return new ConcreteProductB ( ) ; } } interface Product { operation ( ) : string ; } export class ConcreteProductA implements Product { public operation ( ) { return 'ConcreteProductA' ; } } export class ConcreteProductB implements Product { public operation ( ) { return 'ConcreteProductB' ; } }