Introduction

Completed

JavaScript doesn't support interfaces so, as a JavaScript developer, you may or may not have experience with them. In TypeScript, you can use interfaces as you would in traditional object-oriented programming. You can also use interfaces to define object types and this is the primary focus of this module.

Learning objectives

After completing this module, you will be able to:

  • Explain the reasons for using an interface in TypeScript.
  • Declare and instantiate an interface.
  • Extend an interface.
  • Declare an interface with custom array types.

Prerequisites

  • Knowledge of TypeScript
  • Familiarity with JavaScript
  • Familiarity with functions and arrays in JavaScript
  • Installed software:
    • Git

    • Visual Studio Code

    • Node.js

    • TypeScript - TypeScript can be installed after installing Node.js after running the following in a terminal or command window:

      npm install -g typescript
      

For best results, follow the complete instructions for setting up your environment and using the TypeScript compiler in Module 01: Get started with TypeScript. After setting up your environment, you can run any of the Lab setup or solution files in the Build JavaScript applications by using TypeScript learning path.