TypeScript
From static types, interfaces and generics to utility types, type-level programming, the compiler's configuration, functional and object-oriented styles and TypeScript on the server, TypeScript as told through the free samples of the Leanpub books about it.
Created from the free samples of 11 Leanpub books and the descriptions and tables of contents of 20 more, with every source cited.
TypeScript is a programming language that adds static types to JavaScript. Every JavaScript program is also a TypeScript program; what the language contributes is a way of stating what kind of value each variable, parameter and result may hold, and a compiler that checks those statements before the program runs and then removes them, leaving ordinary JavaScript. One guide on this shelf defines a type as a way of describing the shape and structure of data, and the language as a statically typed superset of JavaScript that adds annotations and checking;[1] another gives the reasons usually offered for adopting it, that errors are caught early, code is more robust and large teams work together more easily.[1]
The language has grown well beyond annotation. An advanced book describes its type system as a programming language in its own right, evaluated entirely during compilation, and complains that too many developers treat it as a passive checker.[16] At the other end, the need for a separate compilation step, long the price of using it, is disappearing, since the common runtimes can now execute TypeScript directly by stripping the types in memory.[18] In between, TypeScript has become the language in which most new books on front-end frameworks, server-side JavaScript and AI applications write their examples, so that a shelf of books tagged with its name is largely a shelf of books about something else, written in it.
This article covers where to begin, the history, the type system, the compiler and its tooling, programming styles, TypeScript with frameworks and on the server, and the quality of code. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it.
Where to start
The introductions assume JavaScript. Essential TypeScript (2016), the best seller on the shelf and its oldest book, presents the language as JavaScript made fit for large applications and starts with installing the compiler and with the newer JavaScript features on which TypeScript builds.[13] Object-Oriented Programming In TypeScript: A Beginner's Guide (2024) and Functional Programming in TypeScript: An Approachable Guide (2024), short guides by one author, each spend a first chapter on variables, types, interfaces, functions and generics before turning to a style of programming.[3][4] A reader with no programming at all has Programming for QA: Python, JavaScript, and TypeScript from Zero to Fluent, written for software testers, which teaches three languages side by side and asks for neither a degree nor prior experience, only about two hundred hours.[6]
Developers who already use the language can go to its particular corners. 50 TypeScript F*ck Ups (2024) is a catalogue of common mistakes;[14] Mastering TypeScript Core Utility Types (2024) is for newcomers and experienced developers alike who want one feature understood thoroughly;[1] Advanced TypeScript (2020) and TypeScript Metaprogramming. Advanced Type Gymnastics, Modern Decorators, and Compiler Internals are for those who want types that catch whole classes of error;[15][16] and Creating NPM Package with TypeScript walks through publishing a library.[5]
Those who meet TypeScript through a framework have books that teach the two together: Creating a Wordle Game in React and TypeScript (2023) for beginners in React,[22] the adjacent Large Scale Apps with React and TypeScript (2023) and Large Scale Apps with Vue, Vite and TypeScript (2023) for developers with intermediate skills who are structuring a large application,[8][9] and The Angular and TypeScript Interview Compendium, which is not a first tutorial and says so: it is for engineers preparing for senior interviews, for TypeScript developers moving to the framework, and for those whose experience was formed on the framework's older style.[7]
History
TypeScript was released by Microsoft in 2012, when JavaScript, designed in the 1990s for small scripts in web pages, was being used for applications of hundreds of thousands of lines. Earlier attempts to tame it had replaced the language with another; TypeScript kept it and added an optional layer of types. Adoption followed that of the frameworks which took it up, one of which was rewritten in it in 2016, and by the 2020s most widely used JavaScript libraries shipped with type definitions. The compiler has since acquired a type system of unusual expressive power, and the runtimes have begun to accept the language without a build step.
The books span that decade. Essential TypeScript (2016) argues the case that had then to be made: JavaScript is old and its dynamic nature makes large applications hard to maintain, and static typing at compile time turns it into something fit for an enterprise, while remaining compatible with the JavaScript already written.[13] By 2020 Advanced TypeScript could take the basics for granted and give its space to strictness flags, generics and the composition of types.[15] The newest titles take up the two ends described above, type-level programming and execution without a toolchain, the second under the phrase toolchain tax for what configuration and transpilation used to cost.[16][18] The functional programming books record a smaller history: in 2021 one author found only a few functional libraries for the language, two of them mature enough for production.[2]
The type system
The basic types are those of JavaScript's own values, booleans, numbers and strings, and a variable is declared with its type after its name. Object-Oriented Programming In TypeScript: A Beginner's Guide likens a variable to a box and the type to a statement of what the box may hold.[3] Mastering TypeScript Core Utility Types runs through the rest in a few pages: arrays of one element type; tuples, which are arrays of fixed length whose positions may differ in type; enumerations of named constants; object types, usually written as interfaces that list properties; and function types, which give the types of parameters and of the result.[1]
What distinguishes the language is how types combine. A union type lets a value be one of several types and an intersection requires it to satisfy several at once; a literal type restricts a value to particular constants, so that a direction can be declared to be one of four words and a fifth is rejected by the compiler; an alias gives a name to any such construction. Annotations are often unnecessary, because the compiler infers a type from the value first assigned.[1] Generics, which let a function or type be written once for many types, are introduced in the first chapter of both beginner guides, and the usual first example is a function that returns its argument unchanged, whatever the argument's type, without losing track of what that type is.[3][4][1]
Utility types and type-level programming
Utility types are types that transform other types: they adjust an existing type to make a new one, so that the new one need not be written out again. Mastering TypeScript Core Utility Types is devoted to the six it calls core, which make every property of a type optional, required or read-only, build an object type from a set of keys, or select or omit named properties, and treats each with its syntax, examples, uses and pitfalls. Its introduction lists a second group as advanced: types that unwrap the result of an asynchronous operation, remove members from a union or keep only some, exclude the null and undefined values, and extract the parameter types or the result type of a function. The benefit claimed is less repeated code in large projects, where types are reused most.[1] Advanced TypeScript goes on to conditional and mapped types and to unions whose members are told apart by a tag, and promises its reader fluency in the compiler's error messages.[15] TypeScript Metaprogramming. Advanced Type Gymnastics, Modern Decorators, and Compiler Internals carries the idea to its conclusion, programs written in the type system itself, with the aim of architectures in which invalid states cannot be represented, and adds decorators and the compiler's own programming interface.[16]
Types are erased when the program is compiled, which leaves a gap wherever data arrives from outside at run time. The TypeScript-First Architect. Building Robust Applications with Effect, Zod, and Drizzle is about closing that gap with libraries that validate data against a schema from which the static type is derived.[17] The Angular and TypeScript Interview Compendium expects a candidate to reason about the same boundary: its preface lists the difference between the two types that accept any value, one unchecked and one that must be narrowed before use, among the things a reader will be able to explain, together with saying precisely where the language's guarantees end, at the boundaries where erased types meet real data. The book gives the language three chapters of its own before the framework, on fundamentals and narrowing, on generics and advanced types, and on those boundaries with modules and configuration policy, and closes with scenarios in reading and debugging TypeScript code.[7] The commonest errors in all of this are the matter of 50 TypeScript F*ck Ups, which describes more than a hundred anti-patterns and slips under fifty headings, on the principle that the best mistakes are the ones avoided, and warns that they catch experienced developers too.[14]
The compiler and its tooling
The compiler is installed as a development dependency, since those who use a finished package do not need it, and is governed by a configuration file whose folder it treats as the root of the project. Creating NPM Package with TypeScript explains this in the course of building and publishing a small library, and shows why a package may need several such files, for building, for testing and for the editor, and separate outputs for the two module systems that JavaScript has acquired. Its base file turns on strict checking, refuses to emit any JavaScript while errors remain, and reports a function with a path that returns nothing and variables or parameters that are never used. A second file inherits those settings and only checks, emitting nothing; a third, for tests, has each file translated in isolation and leaves the resolving of imports to the test runner; two more write the compiled library to separate folders, one for each module system, with declaration files that carry the types to the package's users. Every option is explained where it is set.[5] Functional Programming in TypeScript: An Approachable Guide ends with an example of a strict configuration,[4] and the strictness flags that make the compiler catch more are the first subject of Advanced TypeScript.[15]
Running the result has become simpler. Programming for QA: Python, JavaScript, and TypeScript from Zero to Fluent has its beginners install the compiler together with a tool that runs TypeScript files directly, and its first chapter shows the same greeting program in three languages. The book teaches every concept three times, on the reasoning that testers work across all three: one language dominates the testing of servers and interfaces, JavaScript drives the browser, and TypeScript adds type safety to it and is the default of the newer test frameworks. A tester who cannot program, it says, is limited to the tools that other people build, and its examples are taken from the work itself, parsing test results, validating the responses of an interface and processing log files.[6] The Native Era. Modern Node.js, Bun & Deno without Bundlers or Transpilers is a whole book on building and deploying server-side programs on three runtimes without bundlers or transpilers.[18]
Programming styles
TypeScript supports both of the styles that divide programmers, and has books on each. Object-oriented programming, in the words of the beginner's guide to it, models real things as objects that hold data and behaviour, and makes code more modular and maintainable; its sample includes a glossary that runs from abstract classes, which exist only to be extended, through composition and encapsulation to inheritance and interfaces.[3] Functional programming treats computation as the evaluation of functions and avoids changing state, and the companion guide argues that static types make TypeScript a good language in which to learn it, adds that the paradigm's roots in mathematics do not mean a reader must be a mathematician, and builds from foundations to a chapter that applies them in a project.[4]
The functional shelf is the deeper. Functional Programming in Typescript (2021) is a practical introduction built on one library.[19] Functional Programming in TypeScript (2025) occupies what it calls the middle ground between introduction and theory, presenting ideas from category theory only so far as they can be shown in code, and beginning with lenses and monoids, the second being values with an empty element and a way of combining. A lens is reached in steps from familiar ground. A class with a private field has a getter; the getter can be lifted out as a plain function and passed to the method that maps over a list; a setter can be written in the same way, provided that it returns an updated copy of the object and leaves the original alone; and the pair of them, held in one object, is a lens. Its author asks for pragmatism: purity is not an end in itself, and a programmer should be willing to return to an object-oriented style where that serves the organisation better. The same test is applied to the mathematics, on the view that an idea which cannot easily be shown in code is unlikely to become part of a developer's working repertoire.[2] The Effect Book: Building Robust Typescript Applications teaches a library that handles errors, dependencies, retries and asynchronous work in one model, for developers already comfortable with the language's asynchronous functions.[20] Multi-Paradigm Programming (2025) declines to choose, and shows functional, object-oriented and imperative techniques, with some taken from Lisp, combined in one language; its opening chapter traces how modern languages came to accept several paradigms at once.[21]
Frameworks and the server
Most TypeScript is written inside a framework, and the adjacent books show what the types are for there. Large Scale Apps with React and TypeScript and Large Scale Apps with Vue, Vite and TypeScript, by one author, each grow a large front end step by step and list type checking at development time, which reduces errors at run time, beside naming conventions, component libraries and unit tests among the practices of a maintainable application, together with support for several languages and the composing of behaviour from small reusable functions.[8][9] SolidJS: The Complete Guide (2025) writes its examples in TypeScript while assuring readers who have never used it that anything complex, or anything that depends on a particular compiler setting, will be explained.[10] Next.js – The Comprehensive Guide builds one application, a help desk with AI features, for experienced TypeScript or JavaScript developers and for those arriving from other languages, says what the project deliberately keeps simple, and offers different reading paths according to the reader's background.[11] Creating a Wordle Game in React and TypeScript teaches components and hooks through a word game, with an appendix on the language,[22] and Mastering React.js Interviews (2025) types the examples in its answers.[12]
On the server the language is used for the same reasons. Build Your Own Web Server From Scratch In Node.JS (2024), an adjacent book, codes a web server from a bare network connection upward;[26] Event-Driven Architecture & DDD in TypeScript. Event Sourcing, CQRS, and Microservices at Scale and FinTech Architecture in TypeScript. Precision Math, Double-Entry Ledgers, and High-Reliability Payment Pipelines apply it to event-sourced systems and to ledgers and payments, where the second begins with the traps of floating-point arithmetic;[27][28] and Hardened TypeScript. Passkeys, Supply Chain Defense, and Zero-Trust Architectures covers the security of full-stack applications.[29] Two core books apply it to AI: Practical TypeScript Artificial Intelligence Programming introduces machine learning and language models to TypeScript programmers, and AI Engineering with TypeScript goes from a first call to a model to a deployable application.[23][24] In testing, The Pragmatic Comprehensive Senior SDET pairs the language with a browser automation tool for test engineers.[25]
Keeping code healthy
Types do not make code good, and two adjacent books address what remains. Refactoring TypeScript (2019) starts from the piece of code that a team's members hate to touch and that keeps producing bugs, compares code to a garden that becomes overgrown if ignored, and gives each chapter to one kind of weed, such as checks for null scattered everywhere, deeply nested conditions or long lists of parameters, with ways of recognising and removing it.[30] 10 Refactorings to Boost your Clean Code Efficiency (2022) applies ten common refactorings in turn to one small example, using the shortcuts of an editor.[31]
Questions about TypeScript
Which TypeScript book should I start with?
The introductions assume JavaScript, and Essential TypeScript (2016), the oldest book on the shelf, starts with installing the compiler and with the newer JavaScript features on which TypeScript builds.[13] Object-Oriented Programming In TypeScript: A Beginner's Guide (2024) and Functional Programming in TypeScript: An Approachable Guide (2024), short guides by one author, each spend a first chapter on variables, types, interfaces, functions and generics before turning to a style of programming.[3][4] Developers who already use the language can go to 50 TypeScript F*ck Ups (2024), a catalogue of common mistakes.[14]
What is the difference between TypeScript and JavaScript?
TypeScript adds static types to JavaScript, and every JavaScript program is also a TypeScript program. What the language contributes is a way of stating what kind of value each variable, parameter and result may hold, and a compiler that checks those statements before the program runs and then removes them, leaving ordinary JavaScript. Mastering TypeScript Core Utility Types (2024) gives the reasons usually offered for adopting it, that errors are caught early, code is more robust and large teams work together more easily.[1]
What are generics in TypeScript?
Generics let a function or type be written once for many types, and Object-Oriented Programming In TypeScript: A Beginner's Guide and Functional Programming in TypeScript: An Approachable Guide both introduce them in their first chapter. The usual first example is a function that returns its argument unchanged, whatever the argument's type, without losing track of what that type is.[3][4][1] Advanced TypeScript (2020) takes the basics for granted and gives its space to strictness flags, generics and the composition of types.[15]
What are utility types in TypeScript?
Utility types are types that transform other types: they adjust an existing type to make a new one, so that the new one need not be written out again. Mastering TypeScript Core Utility Types (2024) is devoted to the six it calls core, which make every property of a type optional, required or read-only, build an object type from a set of keys, or select or omit named properties.[1] The benefit claimed is less repeated code in large projects, where types are reused most.[1]
Does TypeScript check types at run time?
It does not: types are erased when the program is compiled, which leaves a gap wherever data arrives from outside at run time. The TypeScript-First Architect. Building Robust Applications with Effect, Zod, and Drizzle is about closing that gap with libraries that validate data against a schema from which the static type is derived.[17] The Angular and TypeScript Interview Compendium expects a candidate to say precisely where the language's guarantees end, at the boundaries where erased types meet real data.[7]
Do I still need to compile TypeScript before running it?
The need for a separate compilation step, long the price of using the language, is disappearing, since the common runtimes can now execute TypeScript directly by stripping the types in memory.[18] The Native Era. Modern Node.js, Bun & Deno without Bundlers or Transpilers is a whole book on building and deploying server-side programs on three runtimes without bundlers or transpilers.[18] Creating NPM Package with TypeScript shows the compiler's work for a published library, which it writes to separate folders for the two module systems, with declaration files that carry the types to the package's users.[5]
Sources
Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.
- 1.Mastering TypeScript Core Utility Types, Kristiyan Velkov: The Ultimate Guide from Beginner to Pro: 300+ Examples, Practical Exercises, and Best Practices for Mastering Advanced TypeScript Free sample: the introduction and the review of the language's types that precedes the utility types. 2024. Free sample: PDF
- 2.Functional Programming in TypeScript, dimitris papadimitriou: With categories Free sample: the statement of purpose, the note on libraries and the opening sections on lenses and monoids. 2025. Free sample: PDF
- 3.Object-Oriented Programming In TypeScript: A Beginner's Guide, Adegoke Akintoye : Object-Oriented Programming In TypeScript: A Beginner's Guide Free sample: the preface and the first chapter, on variables, types and interfaces. 2024. Free sample: PDF · EPUB
- 4.Functional Programming in TypeScript: An Approachable Guide, Adegoke Akintoye : functional programming through the lens of TypeScript Free sample: the preface and the first chapter, on setting up and the basic types. 2024. Free sample: PDF · EPUB
- 5.Creating NPM Package with TypeScript, CodeSweetly: Simplified TypeScript Guide to Building and Publishing Libraries Free sample: project setup, installing the compiler and its configuration files. 2026. Free sample: PDF · EPUB
- 6.Programming for QA: Python, JavaScript, and TypeScript from Zero to Fluent, Yuri Syuganov: Three Languages, One Mission: Better Testing Free sample: the introduction, the setup and the first program in three languages. 2026. Free sample: PDF
- 7.The Angular and TypeScript Interview Compendium, Yohan J. Rodríguez: Interview Questions and Answers for Angular and TypeScript Developers Free sample: the preface and the first questions, on components. 2026. Free sample: PDF
- 8.Large Scale Apps with React and TypeScript, Damiano Fusco: Build Large and Scalable front-ends that leverage component isolation, a centralized state manager, internationalization, localization, Custom Component Libraries, API-client code that easily can switch between mocked data and live data and more. Free sample: the overview of the book and the first steps of the project. 2023. Free sample: PDF · EPUB
- 9.Large Scale Apps with Vue, Vite and TypeScript, Damiano Fusco: Build Large and Scalable front-ends that leverage component isolation, internationalization, localization, a modular state manager, component Libraries, API-client code that easily can switch between mocked data and live data and more. Free sample: the overview of the book and the first steps of the project. 2023. Free sample: PDF · EPUB
- 10.SolidJS: The Complete Guide, Sinan Polat: A comprehensive guide to reactive web development with SolidJS and TypeScript Free sample: the scope and requirements of the book and the first project. 2025. Free sample: PDF · EPUB
- 11.Next.js – The Comprehensive Guide, Florian Wessels: From React Fundamentals to AI-Powered Full-Stack Apps Free sample: the introduction, on who the book is for and the project it builds. 2026. Free sample: PDF · EPUB
- 12.Mastering React.js Interviews, Kristiyan Velkov: From 0 to Hero The free sample was consulted for its contents only: from those and the description. 2025. Free sample: PDF
- 13.Essential TypeScript, Jess Chadwick: It's JavaScript... only better. No sample: from the description and table of contents. 2016.
- 14.50 TypeScript F*ck Ups, Azat Mardan: 50 Subtle Mistakes to Screw Your Code and How to Avoid and Fix Them to Write Extraordinary Software for Web No sample: from the description and table of contents. 2024.
- 15.
- 16.TypeScript Metaprogramming. Advanced Type Gymnastics, Modern Decorators, and Compiler Internals, Edgar Milvus No sample: from the description alone. 2026.
- 17.The TypeScript-First Architect. Building Robust Applications with Effect, Zod, and Drizzle, Edgar Milvus No sample: from the description alone. 2026.
- 18.The Native Era. Modern Node.js, Bun & Deno without Bundlers or Transpilers, Edgar Milvus No sample: from the description alone. 2026.
- 19.Functional Programming in Typescript, Sam Van Overmeire: A Practical Guide No sample: from the description and table of contents. 2021.
- 20.The Effect Book: Building Robust Typescript Applications, Jitin Kayyala No sample: from the description and table of contents. 2026.
- 21.Multi-Paradigm Programming, Marty Yoo: Combining Functional, Object-Oriented, and Lisp Paradigms for Software Design and Implementation No sample: from the description, which outlines the chapters. 2025.
- 22.Creating a Wordle Game in React and TypeScript, Mike Gold No sample: from the description and table of contents. 2023.
- 23.Practical TypeScript Artificial Intelligence Programming, Mark Watson: Practical AI Programming with TypeScript — From Classic Machine Learning to Large Language Models and Knowledge Representation No sample: from the description and table of contents. 2026.
- 24.AI Engineering with TypeScript, Kristin and Aaron: A Comprehensive Guide to Building AI Agents No sample: from the description and table of contents. 2026.
- 25.The Pragmatic Comprehensive Senior SDET, AITestGuruPress: Playwright–TypeScript Gems with API and Performance Testing No sample: from the description and table of contents. 2026.
- 26.Build Your Own Web Server From Scratch In Node.JS, build-your-own.org: Learn network programming, HTTP, and WebSocket by coding a Web Server No sample: from the description and table of contents. 2024.
- 27.Event-Driven Architecture & DDD in TypeScript. Event Sourcing, CQRS, and Microservices at Scale, Edgar Milvus No sample: from the description alone. 2026.
- 28.FinTech Architecture in TypeScript. Precision Math, Double-Entry Ledgers, and High-Reliability Payment Pipelines, Edgar Milvus No sample: from the description alone. 2026.
- 29.Hardened TypeScript. Passkeys, Supply Chain Defense, and Zero-Trust Architectures, Edgar Milvus No sample: from the description alone. 2026.
- 30.Refactoring TypeScript, James Hickey: Keeping Your Code Healthy No sample: from the description and table of contents. 2019.
- 31.10 Refactorings to Boost your Clean Code Efficiency, Juntao Qiu: Small steps to make your code more readable. No sample: from the description and table of contents. 2022.
Further reading
Other books in the library that are written in TypeScript, not cited above.
- Clean Code Principles and Patterns, 2nd Edition, Petri Silen: A Software Practitioner's Handbook A large handbook of principles and patterns from architecture and design to testing and security. 2024.
- Serverless Domain Driven Design for the Busy Developer, Oskar Flores Domain-driven design applied to serverless systems on one cloud. 2025.
- Angular Libraries - The Complete Guide, Matt Vaughn Creating, publishing and versioning reusable libraries for one framework. 2021.
- AI Agents in TypeScript, Edgar Milvus Building stateful systems of several AI agents with a JavaScript library. 2026.
- Local-First Systems in TypeScript. Collaborative & Offline-Ready Web Apps with CRDTs and WASM DBs, Edgar Milvus Web applications that work offline and synchronise later, with data kept on the user's device. 2026.
- Building Desktop Apps & Developer Tools with Tauri 2.0, Rust, and TypeScript, Edgar Milvus Desktop applications with a core in another language and a TypeScript front end. 2026.