June 2021
Intermediate to advanced
398 pages
9h 35m
English
Over the course of this book, we’ve been using TypeScript to make assertions about the structure of our code, which has made it easier to validate that our code is correct. Now we’re going to focus on features of TypeScript itself that we can use to enhance the typing of our system, with the goal of making it even harder to write code that puts the system in an invalid state.
Many JavaScript programs use a lot of code to protect against invalid data being passed around, continually performing null checks or other type checks. We can use our TypeScript system to make certain kinds of invalid states impossible without using run-time checks. We can, for example, specify that a certain value can’t ...