Skip to content

TS4125: 'override' modifier cannot be used with 'declare'

Error message

                'override' modifier cannot be used with 'declare' modifier.
              

Quick summary

You cannot use both 'override' and 'declare' on the same class member.

Why this happens

  • Member has both 'override' and 'declare' keywords

Minimal example

✗ Broken code
class Base { greet() {} }
class Child extends Base {
  override declare greet(); // TS4125
}
✓ Fixed code
class Base { greet() {} }
class Child extends Base {
  override greet() { super.greet(); } // ✅
}

Use only 'override' if the method has an implementation.

How to diagnose

  • Check the member's modifiers

  • Determine if the member is an override or a declaration

How to fix

  • Remove 'declare' if the member has an implementation and overrides a base member

  • Remove 'override' if the member is only declared (no implementation)

← Back to language