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{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.
TypeScript Version: 3.7.2
Search Terms:
typescript property access super undefined
Code
Expected behavior:
Should be some sort of type error, because clearly it is undefined
Actual behavior:
no error until runtime
Playground Link
The text was updated successfully, but these errors were encountered: