Skip to content

Supporting type self or something that can represents the current instance. #2179

Closed
@vilicvane

Description

@vilicvane

When I am writing a declaration file, I found it really frustrating repeating the inherited method that returns the instance itself for a correct return type.

E.g. for animation library GSAP, many classes are inherited from class Animation, I have to repeat almost every method to update return type Animation to the current class.

class Animation {
    chain(): Animation;
}

class TweenLite extends Animation {
    ownProperty: any;
    chain(): TweenLite;
}

It would be great if we may use some type like self to make this easier, like this:

class Animation {
    chain(): self;
}

class TweenLite extends Animation {
    ownProperty: any;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions