Skip to content

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

@Jack-Works

Description

@Jack-Works

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions