Adapter — The Boundary Structural Subtyping Removes
TypeScript uses structural subtyping, so anything whose shape matches can be passed straight through without an explicit implements. This chapter looks at where the need for a converter in between still remains.
Builder — Staged Construction Expressed with Object Literals and Types
An object with many optional arguments can be assembled from a literal. An ordering constraint such as "you cannot build until this value is set" is something TypeScript's types can express.
Chain of Responsibility — The Middleware Shape
The structure of handing a request along step by step is widely used as middleware in Node.js. This chapter goes as far as building context up through types.
Composite — Recursive Discriminated Unions
When you handle a tree, a recursive discriminated union can stand in for a class hierarchy built on a shared interface. The subject here is a file system.
Decorator — A Pattern Distinct from TC39 Decorators
Despite the shared name, GoF's Decorator pattern and TypeScript's Decorators syntax are different concepts. This chapter separates the two, then compares the pattern with composition through higher-order functions.
Factory Method and Abstract Factory — Moving Creation into Functions
In TypeScript, pulling creation logic out usually needs nothing more than a plain function and a union of literal types. Abstract Factory only earns its place when a constraint ties several related products together.
Iterator — The Pattern the Language Absorbed
The abstraction of iteration is in the language specification as Symbol.iterator and generators. This chapter checks whether any reason remains to write an Iterator class of your own.
Observer — The Mechanism the Platform Already Has
Before you build a notification mechanism of your own, there are standard tools: EventTarget and AbortSignal. This chapter looks at how far the standard gets you, unsubscription included.
Proxy — A Different Concept That Shares a Name with the Built-in Proxy
JavaScript has a built-in object called Proxy, and it is not the same thing as GoF's Proxy pattern. This chapter covers both, using lazy loading and access logging as its subjects.
Repository — A Pattern Outside GoF That Comes Up Often in Practice
Repository comes from PoEAA, not GoF. To avoid overlapping with the existing articles, this chapter narrows to how TypeScript's types express this boundary.
Singleton — How Far a Module's Single Instance Reaches
An ES module is evaluated only once as long as it resolves to the same URL, so you get a single instance without writing a Singleton class. This chapter maps how far that guarantee reaches and when you still need another approach.
State — Killing Invalid Transitions with Types
Instead of a class per state, representing states with a discriminated union lets the type forbid operations the current state cannot accept. The subject here is a vending machine.
Strategy — Functions Being First-Class
If all you do is swap behavior, passing a function is enough. What still makes you want to bundle things into an object is a strategy that carries several methods or state.
Summary — The Patterns Without a Chapter, and the Full List of Judgments
A short take on the eight patterns that got no chapter of their own, plus every judgment in the series collected into one table. It also lays out the steps for deciding whether to use a pattern.
Template Method — Inheritance and Injecting Hooks
Inheriting from an abstract class is not the only way to fix the skeleton of a procedure and swap out one part of it. This chapter sorts out how that differs from taking hook functions.
TypeScript Design Patterns
A 16-chapter guide that rereads the 23 GoF patterns in modern TypeScript. Each chapter judges whether language features can replace the pattern, and lays out the conditions under which writing it as a class still pays off.
Visitor — The Exhaustiveness Check Stands In for It
With an exhaustiveness check built from a discriminated union and never, the type prevents forgotten cases without assembling Visitor's class hierarchy. The subject here is a syntax tree.