0Pricing
TypeScript Academy · Lesson

Type Aliases and Interfaces

Compare and use type aliases and interfaces.

1

Type Aliases and Interfaces

Welcome to the next lesson! In this lesson, you’ll learn about type aliases and interfaces in TypeScript, including their differences, similarities, and when to use each. Let’s get started!

Type Aliases and Interfaces — illustration 1

2

What Are Type Aliases?

A type alias allows you to define a custom name for a type. It can represent primitive types, objects, or even function signatures.

Example:

Task: Create a type alias for an object representing a book and use it to define a variable.

type Point = {
  x: number;
  y: number;
};

let point: Point = { x: 10, y: 20 };
console.log(point); 
// Output: { x: 10, y: 20 }

All lessons in this course

  1. Generics
  2. Type Aliases and Interfaces
  3. Utility Types
  4. Type Guards
← Back to TypeScript Academy