Skip to content

Optional abstract members #6413

Closed
Closed
@tinganho

Description

@tinganho

I want to be able to make the implementation optional for abstract member, but it seems like it is not doable today.

abstract class Component {
    public abstract setText?(l: GetLocalization): void;
    public abstract bindInteractions?(): void;
}

I have some component classes and they MUST extend the base component class and optionally implement certain methods with a certain signature. Right now, I can only rely on good documentation.

class Post extends Component {
    public setText(l: GetLocalization): void {
        //...
    }
    // Though I don't want to implement bindInteractions method.
}

I want the power of auto-completion to also kick in.

Why is this useful?

It is useful for classes with life cycle methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarifiedSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions