Course contentsShow
← TypeScript
Lesson 1211 of 1,79628. tsconfig in DepthFree lesson

noImplicitOverride: Protecting Against Accidental Overrides

Require explicit override keyword when extending classes to prevent unintended method shadowing.

noImplicitOverride: Protecting Against Accidental Overrides

What you'll learn: How to use the noImplicitOverride compiler flag to require explicit override keywords when extending classes, preventing unintended method shadowing.

The Problem: Silent Overrides

When you extend a class in TypeScript, you can accidentally override a parent method without realizing it. Maybe you renamed a method in the base class but forgot to update the subclass. Maybe you added a new method to the subclass that happened to match a base class method name. Without noImplicitOverride, TypeScript stays silent—your override happens implicitly, potentially breaking your program's logic.

Think of it like inheriting a family business. If you start using the company name for a completely different venture without telling anyone, customers expecting the original service will be confused. An explicit declaration ("Yes, I'm intentionally changing how this works") prevents accidental conflicts.

How noImplicitOverride Works

When you enable noImplicitOverride in your tsconfig.json, TypeScript enforces a simple rule: any method in a subclass that overrides a parent method must use the override keyword.

This creates a contract: "I know this method exists in the parent, and I'm deliberately replacing it." If the parent method gets renamed or removed, TypeScript will immediately flag your override keyword as an error—alerting you that your override target no longer exists.

Configuration

{
  "compilerOptions": {
    "noImplicitOverride": true
  }
}

With this flag enabled, you must explicitly mark overriding methods. Without it, any method in a child class can silently shadow parent methods.

Key Takeaway:

noImplicitOverride requires you to explicitly mark method overrides with the override keyword, protecting against accidental shadowing and ensuring you're intentionally replacing parent class behavior—especially valuable when base classes evolve over time.