title: Is it possible to access an attribute of a child class from the parent class?
body: <p>I have a parent class where I am defining store-relation function, and a child class which defines its table on the store. In the parent class, I'm defining a <code>save()</code> function which connects to the instance's table, but the table is defined on the child. I figured I could just set the constructor of the parent to accept the child's <code>tableName</code>, but my linter is complaining that <code>super</code> must be called before I reference <code>this</code> (even though I want to pass an attribute on <code>this</code> up to super). </p>
  
  <p>Here's the parent:</p>
  
  <pre><code>export class StoredObject {
      constructor(private tableName: string) {}
  
      public save() {
          store.collection(this.tableName) //...
      }
  }
  </code></pre>
  
  <p>And the child:</p>
  
  <pre><code>export class Inventory extends StoredObject {
      tableName = "inventory";
  
      constructor(
          public myVar //...
      ) {
          super(this.tableName)
      }
  }
  </code></pre>
  
  <p>I know one solution is to make a getter function that simply returns the value of <code>this.tableName</code>, but that seems hackish. I also know that I could simply put the actual string in <code>super</code> (e.g., in <code>Inventory</code>, have the constructor be <code>{ super("inventory") }</code>, but that seems inelegant. I get the suspicion there is a way of conventionally achieving what I'm trying to do, but I can't seem to find it.</p>