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
The requirement is to prevent this.doot from referring to a Thing even when we're in a subclass and this should refer to the subclass.
classThing{doot!: this;dothing(newthing: this){this.doot=newthingasany;// There's a reason the cast is needed!}}classSubThingextendsThing{constructor(readonlyfoot: number){};}consts=newSubThing();s.dothing(newThing());console.log(typeofs.doot.foot==="number");// Expected this to always be true!
ghost
added
the
Question
An issue which isn't directly actionable in code
label
Mar 9, 2018
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version:
Version 2.8.0-dev.20180302
Search Terms:
type, this
Simplest Code
Expected behavior:
No error
Actual behavior:
Error Type 'Thing' is not assignable to type 'this'.
Note
Since there is no 'typeof this' operator that I can use, I need to use this to represent types that have the same type as this.
Playground Link
Slimmed down real world example
Related Issues:
8164
The text was updated successfully, but these errors were encountered: