/**
 * Visitor is a behavioral design pattern that separates
 * algorithms from the objects on which they operate.
 */ interface Visitor { visitConcreteComponentA ( element ) : string ; visitConcreteComponentB ( element ) : string ; } export class ConcreteVisitor implements Visitor { visitConcreteComponentA ( element ) { return element . name ; } visitConcreteComponentB ( element ) { return element . name ; } } interface Element { accept ( visitor ) : string ; } export class ConcreteElementA implements Element { public name : string = 'ConcreteElementA' ; public accept ( visitor ) { return visitor . visitConcreteComponentA ( this ) ; } } export class ConcreteElementB implements Element { public name : string = 'ConcreteElementB' ; public accept ( visitor ) { return visitor . visitConcreteComponentB ( this ) ; } }