Skip to content

Inheritance and static members #5989

Closed
Closed
@benzid-wael

Description

@benzid-wael

I think that is useful to access to static members :

  • from instances
  • from sub classes

Below an example:

class A {
  protected static type: string;

 public log(): string {
    console.log(this.type);
  }
}

class B extends A {
  protected static type: string = 'C';
}

class C extends A {
  protected static type: string = 'C';
}

b = new B();
b.log(); // => 'B'

c = new C();
c.log(); // => 'C'

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions