Skip to content

noImplicitOverride does not complain on abstract methods #44457

Closed
@Lusito

Description

@Lusito

Bug Report

When using noImplicitOverride, I would expect a missing override to complain for abstract methods as well.

🔎 Search Terms

noImplicitOverride abstract

Found #13729, which states "Let's say no for now.", but I would argue against that.

🕗 Version & Regression Information

TypeScript 4.3.2 and Nightly

  • I was unable to test this on prior versions because this is a new feature

⏯ Playground Link

Playground link with relevant code

You'll need to manually set the tsconfig option in the Playground, as the share link doesn't seem to contain that option.

💻 Code

abstract class Hello {
    abstract doesNotComplain(): void;
}

class World extends Hello {
    // should complain here for missing override keyword
    doesNotComplain() {}
}

🙁 Actual behavior

With noImplicitOverride=true, tsc is fine with the above snippet

🙂 Expected behavior

With noImplicitOverride=true, it should complain about the missing override keyword.

Reasoning

I can add an override keyword for implementations of abstract methods. So if I can define it as override, there must be an implicit override if I don't write it manually and the option noImplicitOverride should catch that.

Why do I want this to happen aside from the confusing/incorrect wording of the option?

If I use the override keyword manually, I get an error if the base class removes the abstract method declaration and I can properly update my code. If I didn't have the override keyword, I would have dead code, which needs to be handled differently in newer versions of the base class (for example by registering an event listener instead of implementing an abstract method).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions