Chapter 2. Basic and custom types

This chapter covers

  • Declaring variables with types, and using types in function declarations
  • Declaring type aliases with the type keyword
  • Declaring custom types with classes and interfaces

You can think of TypeScript as JavaScript with types. That’s an oversimplified statement because TypeScript has some syntax elements that JavaScript doesn’t (such as interfaces, generics, and some others). Still, the main power of TypeScript is types.

Although declaring types of identifiers before their use is highly recommended, it’s still optional. In this chapter, you’ll start getting familiar with different ways of using the built-in and custom types. In particular, you’ll see how to use classes and interfaces to declare ...

Get TypeScript Quickly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.