-
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
Multiple Call to super in child class constructor does not give any error #5317
Comments
you cannot use this before super call... |
Actually 'this' is working before super call, you can call super anywhere in the constructor |
@zeeshanhanif OK, your statement has surprised me. My understanding is that this usage in constructor is prohibited under super call is fully resolved. Could you point me to specification of ES6 that allows that free this usage in derived class constructor with super somewhere in the middle? |
Well, while not the ES6 Specification, MDN shows clearly that is valid. The specification makes no assertions to the positioning of the super call (or the number of times) as well. |
Can you reread Description section from your first link (MDN) the one after Syntax and before Example?
|
@wgebczyk |
OK, we misunderstood each other. You are saying that now it works, but it should not. :) I tried to say the same thing :) |
Yes, if we are following object oriented style like Java or C# then super can only be called in first line of constructor and only at once. But I'm not sure if current behavior in typescript is expected or not |
In [https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals] in Goals in point 6: |
Ok, means we should expect that it will be restricted in future. |
this should be handled by #4211 |
A call to super multiple times in Child class' constructor does not give any error, is it expected behavior? Dose it initiate multiple parent objects?
The text was updated successfully, but these errors were encountered: