-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Quick fix: "Implement inherited abstract class" should add override keyword to methods #50464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@RyanCavanaugh Should |
There's only one answer that results in no errors, right? I think I'm missing something |
We don't error on an abstract implementation member that omits |
@a-tarasyuk did you mean to ask whether we should only add |
@JoshuaKGoldberg I meant that // @noImplicitOverride: true
abstract class A {
abstract m(): void;
}
class B extends A {
// ok
m(): void {
throw new Error("Method not implemented.");
}
}
class A1 {
m() {}
}
class B1 extends A1 {
// requires override
m(): void {
throw new Error("Method not implemented.");
}
} |
@DanielRosenwasser can you link to the design notes or maybe explain why |
Thanks, that makes a lot of sense. So why would we want to put |
Well, I think we kind of messed up with Maybe the simplest argument, having put ourselves in this position, is that it's easier to remove the extra |
Suggestion
π Search Terms
quick fix, code action, override
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
When selecting the quick fix action
Implement inherited abstract class
the generated method signatures should include the override keyword which has been present since version 4.3.instead of
π Motivating Example
The autogenerated
@Override
annotation in Eclipse/java has helped me catch many subtle bug which would have otherwise taken a long time to track down. No harm is done adding the keyword automatically as it will promote the usage of said keyword to a wider audience which will result in better quality code down the line.In conjunction with changes like #8306 typescript's OOP would simply be less error prone due to stricter enforcements down the line.
The text was updated successfully, but these errors were encountered: