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
(I'm commenting here because the linked issues are locked)
One could imagine that instance-only properties could be made optional in the prototype type. But I'm sure this would break all kinds of things (I'm pretty sure x instanceof C narrows x to C['prototype'], which would be a funny thing to do if the prototype were wider than C) and not add much value.
TypeScript Version: TypeScript official playground
Search Terms:
Code
Expected behavior:
TypeScript compiler should complain about the
Hello.prototype.abc
, becauseabc
is an instance property not in theHello.prototype
.Actual behavior:
The code works fine in TypeScript playground, no compiling errors.
Playground Link: http://www.typescriptlang.org/play/index.html#src=class%20Hello%20%7B%0D%0A%20%20%20%20abc%20%3D%20%7B%0D%0A%20%20%20%20%20%20%20%20a%3A%20'l'%2C%0D%0A%20%20%20%20%20%20%20%20b%3A%201%2C%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20k%20%3D%20(prop%3A%20keyof%20typeof%20Hello.prototype.abc)%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20console.log(prop)%0D%0A%20%20%20%20%7D%0D%0A%7D
The text was updated successfully, but these errors were encountered: