Visitor Pattern in TypeScript

Your object structure inside an application may be complicated and varied. A good example is what could be created using the Composite structure.

The objects that make up the hierarchy of objects, can be anything and most likely complicated to modify as your application grows.

Instead, when designing the objects in your application that may be structured in a hierarchical fashion, you can allow them to implement a Visitor interface.

The Visitor interface describes an accept() method that a different object, called a Visitor…




A Design Pattern is a description or template that can be repeatedly applied to a commonly recurring problem in software design. A familiarity of Design Patterns is very useful when planning, discussing, managing and documenting your applications from now on and into the future.

Recommended from Medium

Getting started with Clipanion, the CLI library that powers Yarn Modern

Webpack- The easiest way

The Letter P Difference, .slice() vs. .splice()

Get Started with React Testing Library and Jest

How To Build Sudoku in Vue.js

Understanding Smile — A data format based on JSON

A Comprehensive Guide to TypeScript Interfaces

Truthy and falsy values in javascript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Bradley

Sean Bradley

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.

More from Medium

State Pattern in TypeScript

30 Day Typescript Type Challenge — Challenge 16

Better types for strings and numbers in TypeString using opaque types

Opaque types in TypeScript

React state meets Typescript’s Union type