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

Overriding Interface Properties

You can override properties from the base interface, but the new type must be compatible with the original:

interface Character {
  rank: string | number;
  name: string;
  level: number;
}

interface Wizard extends Character {
  // Wizards only have a number rank
  // This is allowed because
  // `number` is assignable to `string | number`
  rank: number;
  mana: number;
}

But you can't change to an incompatible type:

interface Character {
  rank: string;
  name: string;
  level: number;
}

interface Wizard extends Character {
  // This breaks because `number` is
  // not assignable to `string`
  rank: number;
  mana: number;
}

Assignment

The company uses a shared SystemEvent interface to represent internal system events. We need more specific system event interfaces for handling errors and outages as well as a way to filter for the high-priority events.