TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

The 'this' context of type 'T' is not assignable to method's 'this' of type 'this'.

Open Jack-Works opened this issue 3 years ago • 0 comments

Bug Report

The 'this' context of type 'T' is not assignable to method's 'this' of type 'this'. 'this' could be instantiated with an arbitrary type which could be unrelated to 'T'.(2684)

🔎 Search Terms

class this parameter inheritance super

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about class

⏯ Playground Link

Playground link with relevant code

💻 Code

export class T {
  base(this: this) {}
}
class T2 extends T {
  f(this: this) {
    super.base()
//  ~~~~~
//  The 'this' context of type 'T' is not assignable to method's 'this' of type 'this'.
//    'this' could be instantiated with an arbitrary type which could be unrelated to 'T'.(2684)
  }
}

🙁 Actual behavior

Not works

🙂 Expected behavior

Works

Jack-Works avatar Oct 17 '22 09:10 Jack-Works