Declare and instantiate classes in TypeScript

Intermediate
Developer
Student
Azure

Classes in TypeScript extend the ES6 functionality by adding TypeScript-specific features like type annotations for class members, access modifiers, and the ability to specify required or optional parameters. Another benefit of using TypeScript is that you can use it to develop with classes and then compile them down to JavaScript that works across all major browsers and platforms, as needed.

Learning objectives

In this module, you will:

  • Explain how you can use TypeScript classes describe the shape of objects.
  • Declare a class using TypeScript.
  • Instantiate a class using TypeScript.
  • Apply access modifiers to a class.
  • Define static properties in a class.
  • Declare a class that extends another class.
  • Declare an interface to ensure class shape.
  • Determine when to use an interface or a class to define the structure of an object.

Prerequisites

  • Knowledge of TypeScript
  • Familiarity with JavaScript
  • Familiarity with TypeScript functions and interfaces.
  • Installed software: