Interfaces vs Types alias in TypeScript

The main differences between Interfaces and Types alias in TypeScript are discussed below:

Attributes or function

We can declare an attribute or a function in both cases. They both have the different syntax:

  // Interface
  interface User {
    first_name: string;
    last_name: string;
  }

  interface setName {
    (first_name: string, last_name: string): string;
  }
  // Type alias
  type User = {
    first_name: string;
    last_name: string;
  };

  type setName = (first_name: string, last_name: string) => string;

Both can extend:

  // Interface
  interface User { name: string; }
  interface PremiumUser extends User { is_premium: boolean; }
  // Type alias
  type User = { name: string; };
  type PremiumUser = User & { is_premium: boolean; };
Reference: