We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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, class, field, property
Related: #45712, #42215, which are about allowing legitimate accesses, while this is about disallowing illegal access.
Playground link with relevant code
class A { a = 1; } class B extends A { calc() { // super.a has type number, but should be disallowed const a = super.a + 1; } } new B().calc();
I'm allowed to access super.a, which is undefined at runtime.
super.a
It should be forbidden, because super is an alias for instance.__proto__.__proto__, which is A.prototype, not an instance of A.
super
instance.__proto__.__proto__
A.prototype
A
The text was updated successfully, but these errors were encountered:
I think this is due to the fact that TS has no concept (afaik) of the prototype chain. It thinks super means any instance of A.
Sorry, something went wrong.
Duplicate of #35314. Used search terms: super in:title
super in:title
Oh, oops, used too many keywords in my query. Thanks for pointing out.
No branches or pull requests
Bug Report
🔎 Search Terms
Super, class, field, property
Related: #45712, #42215, which are about allowing legitimate accesses, while this is about disallowing illegal access.
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
I'm allowed to access
super.a
, which is undefined at runtime.🙂 Expected behavior
It should be forbidden, because
super
is an alias forinstance.__proto__.__proto__
, which isA.prototype
, not an instance ofA
.The text was updated successfully, but these errors were encountered: