O'Reilly logo

TypeScript Blueprints by Ivo Gabe de Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Advanced Programming in TypeScript

In the previous chapters, we learned the basics of TypeScript and we worked with various frameworks. We will discover more advanced features of TypeScript in this chapter. This chapter covers the following aspects:

  • Using type guards
  • More accurate type guards
  • Checking null and undefined
  • Creating tagged union types
  • Comparing performance of algorithms

Using type guards

Sometimes, you must check whether a value is of a certain type. For instance, if you have a value of a class Base, you might want to check if it is of a certain subclass Derived. In JavaScript you would write this with an instanceof check. Since TypeScript is an extension of JavaScript, you can also use instanceof in TypeScript. In other typed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required