Book Image

TypeScript 4 Design Patterns and Best Practices

By : Theofanis Despoudis
Book Image

TypeScript 4 Design Patterns and Best Practices

By: Theofanis Despoudis

Overview of this book

Design patterns are critical armor for every developer to build maintainable apps. TypeScript 4 Design Patterns and Best Practices is a one-stop guide to help you learn design patterns and practices to develop scalable TypeScript applications. It will also serve as handy documentation for future maintainers. This book takes a hands-on approach to help you get up and running with the implementation of TypeScript design patterns and associated methodologies for writing testable code. You'll start by exploring the practical aspects of TypeScript 4 and its new features. The book will then take you through the traditional gang of four (GOF) design patterns in their classic and alternative form and show you how to use them in real-world development projects. Once you've got to grips with traditional design patterns, you'll advance to learning about their functional programming and reactive programming counterparts and how to couple them to deliver better and more idiomatic TypeScript code. By the end of this TypeScript book, you'll be able to efficiently recognize when and how to use the right design patterns in any practical use case and gain the confidence to work on scalable and maintainable TypeScript projects of any size.
Table of Contents (14 chapters)
1
Section 1: Getting Started with TypeScript 4
4
Section 2: Core Design Patterns and Concepts
8
Section 3: Advanced Concepts and Best Practices

What this book covers

Chapter 1, Getting Started with TypeScript 4, introduces the TypeScript language, the differences between TypeScript and JavaScript, installing and using the code examples, how to use VSCode with TypeScript, and an introduction to the Unified Modeling Language.

Chapter 2, TypeScript Core Principles, shows how to use advanced types such as utility types, explains classic OOP concepts with TypeScript, explains how to write TypeScript programs in the browser and server environment, and introduces design patterns that you will study in depth in the next chapters.

Chapter 3, Creational Design Patterns, covers the Singleton pattern, the Prototype pattern, the Builder pattern, the Factory pattern, and the Abstract Factory pattern.

Chapter 4, Structural Design Patterns, covers the Adapter pattern, the Decorator pattern, the Façade pattern, the Composite pattern, the Proxy pattern, and the Bridge pattern.

Chapter 5, Behavioral Design Patterns, covers the Chain of Responsibility pattern, the Command pattern, the Mediator pattern, the Observer pattern, the Memento pattern, the State pattern, the Strategy pattern, the Template method pattern, and the Visitor pattern.

Chapter 6, Functional Programming with TypeScript, discusses functional programming concepts, functional lenses, transducers, and monads.

Chapter 7, Reactive Programming with TypeScript, discusses Reactive programming concepts, Futures and Promises, and finally, Observables.

Chapter 8, Developing Modern and Robust TypeScript Applications, describes combining patterns, using utility types, using domain-driven design, and applying SOLID principles.

Chapter 9, Anti-Patterns and Workarounds, discusses class overuse, the dangers of avoiding using runtime assertions, permissive or incorrect types, using idiomatic code from other languages, and type inference gotchas.