-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Comments
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. |
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! |
Can you un-edit the title and log a new issue to track that suggestion? Thanks! |
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? |
@ngates87:Yes. |
@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. |
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!
The text was updated successfully, but these errors were encountered: