Dev Helpers
← Back

Use a protected base method

Use a protected base method using TypeScript.

Open this example in the interactive library

Source code

interface Named {
  name: string;
}
console.log(
  (() => {
    class Base {
      protected label() {
        return "base";
      }
    }
    class Child extends Base {
      read() {
        return this.label();
      }
    }
    return new Child().read();
  })(),
);

Sample output

base