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
{{ message }}
Repository navigation
Accessing property on super should be a type error #35314
classBase{n=3}classFooextendsBase{test(){console.log(super.n)// type system says it should be a number, but it is undefined}}newFoo().test()// logs "undefined"
Expected behavior:
Should be some sort of type error, because clearly it is undefined
This might be a design limitation - TypeScript can’t currently distinguish between prototype properties and own properties of a class type. The type of super is Base, and Base-the-type has a property n, so the typechecker is satisfied.
Activity
fatcerberus commentedon Nov 24, 2019
This might be a design limitation - TypeScript can’t currently distinguish between prototype properties and own properties of a class type. The type of
superisBase, andBase-the-type has a propertyn, so the typechecker is satisfied.Jack-Works commentedon Apr 29, 2023
#54056