3 Best TypeScript Books for Beginners in 2020

typescript-quickly-mockup

TypeScript is perhaps one of the trickiest languages to pick up and learn because TypeScript lives co-dependently with other frameworks and concepts. To learn TypeScript is to learn theory and practical application at the same time.

So how do you begin?

There are not very many books on TypeScript for a couple of reasons:

  • The language is relatively young, which means that it’s turbulent and changes often, which makes writing a book on the topic difficult.

  • TypeScript is challenging to write about. Because TypeScript is so tightly coupled with JavaScript and other concepts, the book needs to be especially opinionated about scope.

Books need to weigh how much modern JavaScript it teaches as well as other programming concepts and frameworks in back- and front-end development. That means each book needs to define what it means to be a “beginner” in the language.

Learning TypeScript with a book is a journey, and this article aims to make your journey a little bit easier by recommending three solid TypeScript books.

TypeScript vs JavaScript: What is TypeScript?

TypeScript is a superset of JavaScript. TypeScript offers all of the same features of JavaScript — and more. Think of yourself pre- and post-morning coffee. Your post-coffee self can do everything your pre-coffee self can — but more and better!

TypeScript is a superset of JavaScript. TypeScript offers all of the same features of JavaScript — and more. Think of yourself pre- and post-morning coffee. Your post-coffee self can do everything your pre-coffee self can — but more and better!

TypeScript compiles into JavaScript, and JavaScript is ultimately what runs on your browser. TypeScript’s purpose is to be compiled into JavaScript. There is more, perhaps to add to the confusion: JavaScript itself is valid TypeScript because TypeScript is a superset of JavaScript. You can simply change your js or jsx file to ts or tsx and congratulations! You’re writing in TypeScript.

If you understand the relationship between CSS and Sass, for example, you have a sense for what this means.

TypeScript was developed by Microsoft as an open source project in 2012. It offers a wealth of features that JavaScript does not offer. One of the most powerful features TypeScript has is robust ways of working with object types. TypeScript throws specific errors to help you debug. TypeScript also compiles into older versions of JavaScript, which allows your applications to be accessible by many browsers.

If you are not comfortable with JavaScript itself, I recommend learning JavaScript before diving into TypeScript. For learning JavaScript, I’ve compiled a list of the best books for learning modern JavaScript.

 

What makes the Best TypeScript Books?

Teaching TypeScript can go in infinite directions. For a great TypeScript book to teach effectively, it must be opinionated.

Teaching TypeScript can go in infinite directions. For a great TypeScript book to teach effectively, it must be opinionated.

TypeScript is a unique language to learn by nature. Because TypeScript compiles into JavaScript, you don’t just learn syntax and features then be on your way.

The best TypeScript books for beginners are opinionated in order to make the best use of TypeScript’s features.

Because JavaScript itself is valid TypeScript, ‘knowing TypeScript’ can be more accurately described as using TypeScripts’ functionality to the fullest.

This can be tricky to maneuver, which is why an opinionated book on not just the functionality, but using TypeScript well, is vital to your success as a TypeScript developer.

For this article, I prioritized books that truly look out to building your skills as a developer — and not just giving you glossary definitions.

A TypeScript book would be best paired with the classic industry book, The Pragmatic Programmer. You want a TypeScript book that is opinionated, but you must also be equipped to think for yourself. The Pragmatic Programmer is the best book to cultivate that skill.

 
 

Best TypeScript Books in 2020

See below for the top 3 best TypeScript books for beginners in 2020.

Book 1: TypeScript Quickly

We use TypeScript daily, and we like it a lot! We really like TypeScript for allowing us to focus on the main problem we’re solving and not on typs in an object’s property name. In TypeScript programs, the chances of getting runtime errors are substantially lower compared to code originally written in JavaScript. We also like that IDEs offer great TypeScript support and literally walk us through the maze of APIs from third-party libraries we use in projects.

TypeScript Quickly

TypeScript Quickly by Yakov Fain and Anton Moiseev is a February 2020 Manning publication that is one of the most well-organized, clear, and practical books I have seen on TypeScript. Every chapter is clear and concise, and you know where you are going every step of the way.

This book is all about helping you become a more productive developer on web or standalone apps. The authors are practitioners, writing for practitioners — so the book outlines the process of building multiple apps using TypeScript and other popular libraries and frameworks. The book assumes knowledge in HTML, CSS, and modern JavaScript already.

A challenge of teaching TypeScript is that TypeScript often doesn’t function alone. The language is often paired with another frontend framework like React or Angular. Like with other books, TypeScript Quickly decides to be opinionated by diving into frameworks as well.

As far as organization goes, TypeScript Quickly is one of the best. Its structure is clean and you know exactly what you are getting into every step of the way.

TypeScript Quickly includes the following sections:

  • Part 1: Mastering the TypeScript syntax, which includes:

    • Chapter 1: Getting familiar with TypeScript, which includes the benefits of programming in TypeScript, Typescript vs JavaScript, how to compile TypeScript code into JavaScript, and how to work with the Visual Studio Code editor.

    • Chapter 2: Basic and custom types, which includes declaring variables with types and using types in function declarations, declaring type aliases with the type keyword, and declaring custom types with classes and interfaces.

    • Chapter 3: Object-oriented programming with classes and interfaces, which includes how class inheritance works, why and when to use abstract classes, how interfaces can force a class to have methods with known signatures without worry about implementation details, and what programming to interfaces means.

    • Chapter 4: Using enums and generics, which includes the benefits of using enums, the syntax for numeric and string enums, what generic types are for, and how to write classes, interfaces, and functions that support generics.

    • Chapter 5: Decorators and advanced types, which includes what the TypeScript decorators are for, how to create a new type based on an existing one using mapped types, how conditional types work, and combining mapped and conditional types.

    • Chapter 6: Tooling, which includes debugging TypeScript code with the help of source maps, the role of linters, compiling and bundling TypeScript apps with Webpack, compiling TypeScript apps with Babel, and how to compile TypeScript with Babel and bundle it with Webpack.

    • Chapter 7: Using TypeScript and JavaScript in the same project

  • Part 2: Applying TypeScript in a blockchain app, which includes:

    • Chapter 8: Developing your own blockchain app, which includes the principles of blockchain apps, what the hashing functions are for, what block mining is, and developing a simple blockchain-based app.

    • Chapter 9: Developing a browser-based blockchain node, which includes creating a web client for a blockchain, creating a small library for hash generation, and running ther blockchain web app and debugging TypeScript in the browser.

    • Chapter 10: Client-server communications using Node.js, TypeScript,a nd WebSockets, which includes why a blockchain may need a server, the longest chain rule, how to create a Node.js WebSocket server in TypeScript, and poractical uses of TypeScript interfaces, abstract classes, access qualifiers, enums, and generics.

    • Chapter 11: Developing Angular apps with TypeScript, which includes a quick intro to the Angular framework, how to generate, build, and serve a web app written in Angular and TypeScript, and how Angular implements dependency injection.

    • Chapter 12: Developing the blockchain client in Angular, which includes reviewing the code of the blockchain web client in Angular and how to run an Angular client that communicates with a WebSocket server.

    • Chapter 13: Devleoping React.js apps with TypeScript, which includes a quick intro to the React.js library, how React components use props and state, and how React components communicate with each other.

    • Chapter 14: Developing a blockchain client in React.js, which includes reviewing a blockchain web client written with React.js, how the React.js web client communicates with the WebSocket server, running a React app that works with two servers in dev mode, and splitting the UI of a blockchain client into components and arranging their communications.

    • Chapter 15: Developing Vue.js apps with TypeScript, which includes a quick introduction to the Vue.js framework, how to jumpstart a new project with Vue CLI, how to work with class-based components, an d how to arrange client-side navigation using the Vue Router.

    • Chapter 16: Developing the blockchain client in Vue.js, which includes reviewing the Vue.js version of the blockchain web client, running a Vue app that works with two servers in dev move, the flow of data, from entering a transaction to generating a block, and arranging communications between the blockchain’s client components.

Book 2: Effective TypeScript: 62 Specific Ways to Improve Your TypeScript

TypeScript has evolved rapidly over the past few years, but my hope is that it has stabilized enough that the content in this book will remain valid for years to come. This book focuses primarily on the language itself, rather than any frameworks or build tools. You won’t find any examples of how to use React or Angular with TypeScript, or how to configure TypeScript to work with webpack, Babel, or Rollup. The advice in this book should be relevant to all TypeScript users.

Effective TypeScript

Effective TypeScript: 62 Specific Ways to Improve Your TypeScript by Dan Vanderkam is a 2020 O’Reilly publication designed specifically to improve your skills as a TypeScript developer.

The beauty of this book is in how opinionated it is, creating rules and preferences to follow all throughout the book. Yet, unlike the others books in this list, it remains isolated from other tools like React or Angular. This book is unique in that it self-purports to be your “second book on TypeScript,” but this book is on the list because of its great quality and value to all learners of TypeScript.

This TypeScript book can be paired with another TypeScript book on this list because the value of this book is unique.

This book is actionable, easy-to-apply, and helps you become a better TypeScript developer right away.

Effective Typescript includes the following sections:

  • Chapter 1: Getting to Know TypeScript, which includes understanding TypeScript vs JavaScript, knowing which TypeScript options you’re using, understanding that cod generation is independent of types, getting comfortable with structural typing, and limiting the use of any one type.

  • Chapter 2: TypeScript’s Type System, which includes using your editor to interrogate the type system, thinking of types as sets of values, knowing how to tell the type of a symbol, preferring type declarations to type assertions, avoiding object wrapper types, recognizing the limits of excess property checking, applying types to entire function expressions, knowing the difference between type and inheritance, and more.

  • Chapter 3: Type Interference, which includes avoiding clustering your code with inferable types, using different variables for different types, understanding type widening, understanding type narrowing, creating objects all at once, being consistent with aliases, using async functions instead of callbacks for asynchronous code, and more.

  • Chapter 4: Type Design, which includes preferring types that always represent valid states, avoiding repeating type information in documentation, pushing null values to the perimeter of your types, and more.

  • Chapter 5: Working with any, which includes using the narrowest possible scope for any type, preferring more precise variants of any to plain any, hiding unsafe type assertions, and more.

  • Chapter 6: Types Declarations and @types, which includes putting TypeScript and @types in devDependencies, understanding the three versions involved in type declarations, exporting all types that appear in public APIs, and more.

  • Chapter 7: Writing and Running Your Code, which includes preferring ECMAScript features to TypeScript features, knowing how to iterate over objects, understanding the DOM hierarchy, and more.

  • Chapter 8: Migrating to TypeScript, which includes writing modern JavaScript, using @ts-check and JSDoc to experiment with TypeScript, using allowJs to mix TypeScript and JavaScript, and more.

You can access this book free for 10 days with O’Reilly Learning.

Book 3: Programming TypeScript: Making Your JavaScript Applications Scale

This book has two aims: to give you the deep understanding of how the TypeScript language works (theory) and provide bucketfuls of pragmatic advice about how to write production TypeScript code (practice).

Because TypeScript is such a practical language, theory quickly turns to practice, and most of this books ends up being a mix of the two[.]

Programming TypeScript

Programming TypeScript: Making Your JavaScript Applications Scale by Boris Cherny is a beginner-friendly book published in May 2019 that is intensely practical and written in a conversational, fun, and humorous style. The book is ‘light’ for its 324 pages and serves as a solid introduction without overwhelm.

Programming TypeScript includes the following sections:

  • Chapter 1: Introduction, which includes a brief description of why you may want to learn TypeScript and unpacks the value of TypeScript type safety.

  • Chapter 2: TypeScript: a 10_—- Foot View, which includes information about the compiler, the type system, TypeScript vs JavaScript, code editor setup, and more.

  • Chapter 3: All About Types, which includes “The ABCs of Types,” listing types order from any to void.

  • Chapter 4: Functions, which includes information about declaring and invoking functions, polymorphism as it relates to functions, type-driven development, and more.

  • Chapter 5: Classes and Interfaces, which includes information about classes and inheritance, super, using this as a return type, interfaces, polymorphism as it relates to classes, mixins, and more.

  • Chapter 6: Advanced Types, which includes information about relationships between types (including subtypes and supertypes), totality, advanced object types, conditional types, and “escape hatches” such as type assertion, nonnull assertions, and more.

  • Chapter 7: Handling Errors, which includes information about returning null, throwing exceptions, returning exceptions, the option type, and more.

  • Chapter 8: Asynchronous Programming, Concurrency, and Parallelism, which includes information about JavaScript’s event loop, working with callbacks, promises, async and await, event emitters, typesafe multithreading, and more.

  • Chapter 9: Frontend and Backend Frameworks, which includes frontend frameworks like React and Angular as well as type safety to your APIs with tools like Swagger, gRPC, and GraphQL. This section also talks about using TypeORM for safe interaction with your database.

  • Chapter 10: Namespaces Modules, which includes information about JavaScript’s history with modules, import and export, namespaces, declaration merging, and more.

  • Chapter 11: Interoperating with JavaScript, which includes information about ambient type declarations, migrating from JavaScript to TypeScript, type lookup for JavaScript, using third-party JavaScript, and more.

  • Chapter 12: Building and Running TypeScript, which includes information about building your typescript project with layout, artifacts, source maps, error monitoring, and more. This section also talks about running TypeScript on the server or in the browser as well as publishing to NPM.

  • Chapter 13: Conclusion

You can access this book free for 10 days with O’Reilly Learning.

 

Conclusion

You are not learning TypeScript alone. TypeScript is always paired with other ingredients — like libraries and frameworks, much like Peanut Butter is always paired with something (like jelly on a sandwich).

You are not learning TypeScript alone. TypeScript is always paired with other ingredients — like libraries and frameworks, much like Peanut Butter is always paired with something (like jelly on a sandwich).

TypeScript is a challenging programming language to learn because it is not TypeScript alone that you are learning. As you may have discovered from the books we covered about TypeScript, every book covers other technologies and always has an opinionated view about coding in TypeScript.

I enjoyed compiling these books for you. What surprised me the most was, for originally being developed in 2012, there is only a handful of quality books published on the topic — and many of them published in 2020.

I suspect that we have not seen the last of TypeScript books. In the coming years, I expect to see more quality books on this topic.

I hope that you find a lot of value from these books. To get the most value from technical books, I offer a free email course on the subject.

Also, if you are interested in finding more quality books about JavaScript and front-end development, you will love this article on the best JavaScript books in 2020. I will see you over there. 👋😊

 

Miranda Limonczenko

Miranda is the founder of Books on Code, with a mission to bring book-lover culture to programmers. Learn more by checking out Miranda on LinkedIn.

http://booksoncode.com
Previous
Previous

5 Best AngularJS Books for a Modern 2020

Next
Next

Best JavaScript Books for Beginners in 2020