-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Make call to super() implicit within constructor #5910
Comments
What would be the default behavior for the parameters? Would they be passed on to the super class constructor if the signature was the same? |
@coreh that would be a possibility, since you can always override it by making an explicit call to |
Gonna add that like C#, Java does the same too for empty super constructors! :D |
TypeScript is and should be a super set of JavaScript ES6 semantics has no implicit call for constructors, if TS supports that, a TS/ES6 class are not identical in behavior. |
As long as some handy feature isn't detrimental to ES6 compatibilty, I don't see why it should be thrown away. Since TS is a compiler/transpiler it can do tricks that raw JS can't after all. |
peraphs there could be a compiler flag like #274 to turn on and off features like this one. |
What if my intention was to call super() after the |
@jasonwilliams200OK the new behaviour would be:
Your special case would be covered by calling super explicitly. (And btw, is it possible to refer to |
Note that this is disallowed in ES6. You cannot access |
@RyanCavanaugh, thanks, |
As mentioned above, we would like to keep the semantics matching JS, and issue warnings to help guide the user the correct behavior. |
Calling
super()
within a constructor is a bit redundant and annoying... can we have it called implicitly if call to super is omitted?For example this
should be equivalent to
(C# also does a similar thing and it's a nice feature).
The text was updated successfully, but these errors were encountered: