You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classBase{method(){}prop=1;getaccessor(){return1}}classDerivedextendsBase{fn(){super.method;// allowed, as expectedsuper.accessor;// allowed for target >=ES2016, expected it to always be allowedsuper.prop;// allowed for target >=ES2016, expected it to always be disallowed, gives 'undefined' at runtime}}
π Actual behavior
For target <= ES5 both super.accessor and super.prop are an error, for target > ES5 both are allowed, although the runtime behavior is exactly the same. This change was introduced in #5860 because back then there was no (reliable) information whether a property was an accessor or a regular property. Now we have that information even in DTS files. The PR comments even mention that this change was not really correct.
Related: #24678 which was marked "Working as intended", although in the comments it was clearly stated that there should've been a compile error.
π Expected behavior
Property access on super allows everything that resides on the prototype (methods and accessors) and disallows instance properties.
Same logic should apply to all target ES versions as the behavior is always the same.
The text was updated successfully, but these errors were encountered:
I just ran into this in Angular development and it took a long time to figure out what was wrong (e.g. dependency injection, etc...). Especially when there are multiple variables at play this would be extremely helpful to have the compiler catch the error.
Bug Report
π Search Terms
super property access
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
For
target <= ES5
bothsuper.accessor
andsuper.prop
are an error, fortarget > ES5
both are allowed, although the runtime behavior is exactly the same. This change was introduced in #5860 because back then there was no (reliable) information whether a property was an accessor or a regular property. Now we have that information even in DTS files. The PR comments even mention that this change was not really correct.Related: #24678 which was marked "Working as intended", although in the comments it was clearly stated that there should've been a compile error.
π Expected behavior
Property access on
super
allows everything that resides on the prototype (methods and accessors) and disallows instance properties.Same logic should apply to all target ES versions as the behavior is always the same.
The text was updated successfully, but these errors were encountered: