title: How do I extend from a generic parameter in TypeScript?
body: <p>I'm working on a pattern where an abstract parent class needs to inherit all the properties of the generic type supplied through its subclasses.</p>
  
  <p>Here's a look at the constructor for the base class which gives a basic idea, and can also be <a href="https://github.com/atrauzzi/anecdote-engine/blob/master/src/Drivers/AzureTables/Entity/Base.ts#L24-L32" rel="nofollow noreferrer">viewed on github</a>:</p>
  
  <pre><code>public constructor(data: T) {
  
      _.assign(this, _.omit(data, [
          "table",
          "id",
          "PartitionKey",
          "RowKey",
      ]));
  }
  </code></pre>
  
  <hr>
  
  <p>What I'm looking for is some way to effectively express <a href="https://github.com/atrauzzi/anecdote-engine/blob/master/src/Drivers/AzureTables/Entity/Base.ts#L16" rel="nofollow noreferrer">this</a>:</p>
  
  <pre><code>export abstract class Base&lt;T extends EntityData&gt; implements Storage.AbstractEntity &amp; T {
  ...
  </code></pre>
  
  <hr>
  
  <p>Unfortunately, this doesn't appear to be supported currently and so I'm at a loss as to how I can make my base class extend its generic parameter such that any class that inherits from it <a href="https://github.com/atrauzzi/anecdote-engine/blob/master/src/Drivers/AzureTables/Entity/AuthorFact.ts#L7" rel="nofollow noreferrer">also receives the properties of the generic type it's encapsulating</a>:</p>
  
  <pre><code>export class AuthorFact extends Base&lt;Author&gt; {
  
      public get RowKey() { return (this as any).id }
  }
  </code></pre>
  
  <hr>
  
  <p>As you can see, I'm forced to remove <code>&amp; T</code> from my base type and use <code>(this as any)</code> to suppress the compiler throwing an error.</p>
  
  <p>What I'd like ultimately is for the type check on <code>.id</code> to succeed, as well as any other properties of <code>Author</code> to be available on the instance I'mm creating.</p>