Skip to content

Type 'this'??? #9063

Closed
Closed
@electricessence

Description

@electricessence

Is there any magic (without insane generics) to define a type that matches 'this'?

For example...

class A {
  me():A {
     return this;
  }
}

class B extends A {
  otherThing():void{}
  me():B {
    return this;
  }
}

Instead of overriding me() can I define a type without adding another generic declaration that simply solves the type of me()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions