-
Notifications
You must be signed in to change notification settings - Fork 12.8k
'call on undefined' error when calling super from overwritten property function #24678
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
Comments
The runtime behavior itself seems appropriate. This is (more or less) the following equivalent code without class properties: class A {
constructor() {
this.myFunc = () => {
return 'a';
};
}
}
class B extends A {
constructor() {
super();
this.myFunc = () => {
return super.myFunc();
};
}
}
const b = new B();
console.log(b.myFunc()); I think what's problematic is that we don't differentiate between a property if it appeared on the prototype vs. on the instance, so we don't issue an error at all which is unfortunate. |
I tested with
|
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Don't use =>, you can write: class A {
public myFunc () {
return 'a';
};
}
class B extends A {
public myFunc () {
return super.myFunc();
};
}
const b = new B();
console.log(b.myFunc()); |
TypeScript Version: 2.8.3, also whichever version powers playground
Search Terms:
Super function method property access cannot read property call of undefined
Code
Expected behavior:
Either:
Actual behavior:
Successfully builds into JS which then fails at runtime
Playground Link: Link
Related Issues:
#4465 and #338 seem related though they focus on getters and setters
The text was updated successfully, but these errors were encountered: