11 Working with classes and interfaces

This chapter covers

  • Working with types for constructor functions
  • Defining classes with type annotations
  • Restricting access to class members with access controls
  • Simplifying classes by using the concise constructor syntax
  • Creating properties that can only be modified in the class constructor
  • Using accessors and auto-accessors
  • Understanding class inheritance
  • Using interfaces and abstract classes
  • Dynamically creating properties with index signatures

In this chapter, I describe the features that TypeScript provides for working with classes and introduce the interface feature, which provides an alternative approach to describing the shape of objects. Table 11.1 summarizes the chapter.

Table 11.1 Chapter summary ...

Get Essential TypeScript 5, Third Edition 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.