We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Extending Multiple Interfaces

You can extend multiple interfaces at once:

type Character = {
  name: string;
  level: number;
};

interface Magical {
  mana: number;
  castSpell(spell: string): void;
}

interface Physical {
  strength: number;
  attack(): void;
}

interface BattleMage extends Character, Magical, Physical {
  combineAttacks(): void;
}

BattleMage now has all 7 properties and methods:

  • name
  • level
  • mana
  • castSpell
  • strength
  • attack
  • combineAttacks

Assignment

We want our support bots to be both conversational and autonomous. Combine the existing interfaces into one powerful bot interface.

  • name: string
  • status: a value union of "online", "offline", or "starting"
  • shutdown: a method with no parameters that returns a string