Skip to content
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

Opt-in when overriding a propery or method #12132

Closed
Llorx opened this issue Nov 9, 2016 · 5 comments
Closed

Opt-in when overriding a propery or method #12132

Llorx opened this issue Nov 9, 2016 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@Llorx
Copy link

Llorx commented Nov 9, 2016

This, more than a proposal, is just a question to see what do you think on this, and maybe create a proposal just in case...

We have 2 classes, A and B extending A.

Now B can override methods and properties from A without noticing, leading to a problem if the override was by accident.

What if when you override, you have to opt-in by adding a decorator? So you will know that you are overriding something and act accordingly (Add the decorator to really override or change the property/method name).

There's already this: #8306 but I think that mine is a bit different.

@jods4
Copy link

jods4 commented Nov 9, 2016

I think this might be #2000?

@Llorx
Copy link
Author

Llorx commented Nov 10, 2016

Yes but no. Is not opt-in : "it is not an error to omit the override keyword from an overridden method."

@jods4
Copy link

jods4 commented Nov 10, 2016

There was a lot of discussions about that.
The outcome from TS team seems to be that there might be a switch to make override mandatory.
From that comment

New commandline switch --noImplicitOverride (feel free bikeshed the name here) makes override mandatory for things that are overrides

@mhegazy
Copy link
Contributor

mhegazy commented Nov 10, 2016

I believe this request is covered by #2000 as @jods4 mentioned.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 10, 2016
@Llorx
Copy link
Author

Llorx commented Nov 10, 2016

This comment is not opt-in. Forces a method with override tag to be overriden if extended, or return error.

And the final keyword prevents the method from being overriden.

I'm talking about something mid-way. Preventing the method from being overriden (like final), but allowing it if you add an special operator.

By the way, seeing the thread topic, I guess that is more appropriate to post there.

PD: And found the only one post telling the same as me: #2000 (comment). Closing this.

@Llorx Llorx closed this as completed Nov 10, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants