Functional Programming in TypeScript
Functional Programming in TypeScript
Summary:
The book "Functional Programming in TypeScript" is a practical guide that will help you master the paradigm of functional programming (FP) in the context of modern strict typing in TypeScript. Unlike abstract academic textbooks, this book focuses on solving real-world problems: data processing, managing side effects, and building composable architectures.
What is this book about?
You will learn how to apply key FP concepts: pure functions, data immutability, function composition, currying, and partial application. Special attention is given to the TypeScript type system: you will learn to use generics, discriminated unions, conditional types, and higher-kinded types to create safe abstractions. Fundamental patterns are covered: functors, monads (Maybe, Either, IO, Task), and monoids. The book includes a detailed analysis of the fp-ts library — the de facto standard for FP in TypeScript.
Who is this book for?
- Backend and frontend developers already familiar with TypeScript or JavaScript who want to write more predictable, testable, and less error-prone code.
- Developers transitioning from OOP to a functional style and wanting to understand how to apply FP in production without losing performance.
- Students and novice programmers learning TypeScript and striving for a deep understanding of types and composition.
What will you learn and master?
- Why immutability reduces the number of bugs and how to ensure it in TypeScript.
- How to build chains of data transformations through composition and pipelines.
- Working with Option, Either, and Task: error handling without exceptions, asynchronicity without callbacks.
- Principles of "type-driven design": creating domain types that make invalid states impossible.
- Refactoring legacy code: step-by-step transformation of imperative code into functional code.
The book contains over 50 practical examples, exercises at the end of chapters, and ready-made recipes for typical tasks (JSON parsing, form handling, working with APIs). The code for each example has been tested on TypeScript 5.x. After reading, you will be able to confidently apply the functional style in commercial projects, reducing the number of bugs and improving the readability of the codebase.
Recommendations
Refactoring C++ Code: A Practical Guide to Improving Architecture and Readability
Clean TypeScript Code: Writing Maintainable and Scalable Code
API Development in Swift: Creating Server Applications for iOS and macOS
Python Cookbook: Recipes and Tips for Python 3 Programming
JavaScript Everywhere
Kotlin: A Quick Start Guide for Beginners