Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Const

override

override marks a derived-class member as an intentional replacement for an inherited member. TypeScript verifies that the base class contains a matching member, while noImplicitOverride can require the annotation across a codebase.

Since
4.3

How it works

The override modifier marks a class member as an intentional replacement for a member inherited from a base class. TypeScript checks that a corresponding member exists in the base class, and noImplicitOverride can require this modifier for every overriding member.

Syntax

class Derived extends Base {
  override member() {}
}

Returns

The overridden member's declared return type; override itself produces no runtime value.

Key points

  • The modifier was introduced in TypeScript 4.3.
  • A marked method must correspond to a same-named member in the base class.
  • The compiler option complements explicit override annotations.

Common mistakes

  • An override modifier is invalid when the base class has no member with the same name.
  • With noImplicitOverride, omitting override from an overriding member is an error.

Example: Explicitly marking an overridden method

class Album {
  setup() {
    return "base setup";
  }
}

class SharedAlbum extends Album {
  override setup() {
    return "shared setup";
  }
}

console.log(new SharedAlbum().setup());

The derived method explicitly declares that it replaces the base method.

When to use it

Detect renamed base members

Refactoring class hierarchies

Make inheritance intent explicit

Large-team development

Enforce override annotations

Strict compiler configurations

Interview questions

QWhat does the override modifier do?

override documents and verifies that a derived-class member replaces a member from its base class. TypeScript reports an error if no same-named member exists in the base class.

Follow-up: How can a codebase require the modifier consistently? Enable noImplicitOverride; then every superclass override must explicitly use override.

QWhy is override useful during refactoring?

The modifier protects against accidental divergence when a base member is renamed. If the derived member is not updated, TypeScript can detect that the claimed override no longer matches.

Follow-up: What configuration complements the modifier? noImplicitOverride turns implicit overrides into errors, making the intent explicit throughout the hierarchy.

QWhen was override introduced, and what option is associated with it?

TypeScript 4.3 introduced override together with the noImplicitOverride option. The modifier applies to members such as methods that are intended to replace inherited members.

Follow-up: What happens if a derived method is merely intended to be new? Leave off override; adding it would cause an error unless the base class declares a matching member.

  • noImplicitOverride
  • extends
  • super

Source: Documentation - TypeScript 4.3. Checked 2026-10-15.