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

Add "virtual" and "override" keywords for methods #1524

Closed
ghost opened this issue Dec 17, 2014 · 7 comments
Closed

Add "virtual" and "override" keywords for methods #1524

ghost opened this issue Dec 17, 2014 · 7 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@ghost
Copy link

ghost commented Dec 17, 2014

I know that my suggestion (as what you see above in the title) is something (not a must)……Well, however, it would be nice if we can use this "syntax suger" to make TypeScript "more professional", the wrapper of js. Those without the "virtual" cannot be overridden. And when you type something like "override", it will offer you functions that can be overridden.

Thanks anyway!

@DanielRosenwasser DanielRosenwasser changed the title [Suggestion] Add "virtual" and "override" to make the function marked as "overridable" Add "virtual" and "override" keywords for methods Dec 17, 2014
@DanielRosenwasser DanielRosenwasser added the Suggestion An idea for TypeScript label Dec 17, 2014
@RyanCavanaugh RyanCavanaugh added the Declined The issue was declined as something which matches the TypeScript vision label Dec 17, 2014
@RyanCavanaugh
Copy link
Member

This would be a breaking change as methods are 'virtual' by default.

it's not even clear what a non-virtual method would mean in JavaScript - there is no such thing as a non-virtual call.

@ghost
Copy link
Author

ghost commented Dec 18, 2014

@RyanCavanaugh:

Well, I've changed my topic into a new section:)

In my mind, TypeScript is a nice skeleton that will force us to write js in a strongly-typed language. So my "virtual" and "override" is just "syntax suger" (at Visual Studio's compliation level) to force clients that some methods inherited from the father class has been overridden, this will make us see clearly what methods have been overridden.

In default, all the public methods are automatically marked "virtual" in default, at some very specific situation, we don't wanna our customers to override some methods but the method is still "public", so I used to think a way that we can cancel adding "virtual" onto the method to mark that the method cannot be overridden.

In another word, this intellisense is really a "breaking change" to be offered to clients, and maybe I can change my suggestion to another one: Can TypeScript add another new key word (something like "sealed" in C#) to mark some public methods cannot be overridden?

Thanks!

@ghost ghost changed the title Add "virtual" and "override" keywords for methods Add "sealed" key word to mark some public/protected methods not be overriden Dec 18, 2014
@ghost ghost changed the title Add "sealed" key word to mark some public/protected methods not be overriden [Suggestion] Add "sealed" key word to mark some public/protected methods not be overriden Dec 18, 2014
@RyanCavanaugh
Copy link
Member

Can you un-edit the title and log a new issue to track that suggestion? Thanks!

@DanielRosenwasser DanielRosenwasser changed the title [Suggestion] Add "sealed" key word to mark some public/protected methods not be overriden Add "virtual" and "override" keywords for methods Dec 18, 2014
@ngates87
Copy link

ngates87 commented Aug 16, 2017

this may be a superfluous suggestion, but maybe one idea, for purely syntactic sugar keyword that maybe wouldn't break anything, is just allow you to have the override keyword after a function, to make it clear that is overriding a specific function?

@RyanCavanaugh
Copy link
Member

@ngates87 #2000

@ghost
Copy link
Author

ghost commented Aug 17, 2017

@ngates87:Yes.
@RyanCavanaugh:Please make my issue open, for #2000 have the same issue.

@kitsonk
Copy link
Contributor

kitsonk commented Aug 17, 2017

@MaleDong #2000 is open, the suggestion is that is the only thing that is being considered and you should add any thoughts to that issue.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants