-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
super in object literal causes error #5441
Comments
As per the ES6/S2015 spec, super is only allowed in classes. In this sample var obj = class extends class {
method() {
console.log('original');
}
}{
method() {
super.method();
console.log('new');
}
};
new obj().method(); |
I didn't decypher the spec document, but the MDN doc says:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super Chrome, Node, Firefox and Babel all call the prototype method here. No error. |
@mrac seems right - nothing in the super keyword spec indicates that it is only valid within a class, and, in fact, there are even places that call out that you can't user |
yes. looking at the final spec that seems the case; though i remember it was not at some point. |
Design meeting resolution: |
The following code should log:
as it does in ES6. Instead in TypeScript 1.6.2 it causes an error:
'super' can only be referenced in a derived class.
Here's the code:
The text was updated successfully, but these errors were encountered: