title: How can I do constructor overloading in a derived class in TypeScript?
body: <p>Assuming I have a 'base' class such as this:</p>
  
  <pre><code>class CcDefinition {
    // Some properties here
  
    constructor (json: string);
    constructor (someVar: number, someOtherVar: string);
    constructor (jsonOrSomeVar: any, someOtherVar?: string) {
      if (typeof jsonOrSomeVar=== "string") {
        // some JSON wrangling code here
      } else {
        // assign someVar and someOtherVar to the properties
      }
    }
  }
  </code></pre>
  
  <p>I want to be able to extend this base class while still supporting constructor overloading.  For example:</p>
  
  <pre><code>class CcDerived extends CcDefinition {
    // Some additional properties here
  
    constructor (json: string);
    constructor (someVar: boolean, someOtherVar: number, someAdditionalVar: string);
    constructor (jsonOrSomeVar: any, someOtherVar?: number, someAdditionalVar?: string) {
      if (typeof jsonOrSomeVar=== "string") {
        super.constructFromJson(jsonOrSomeVar);
      } else {
        super.constructFromDef(someOtherVar, someAdditionalVar);
        // assign someVar to the additional properties of this derived class
      }
    }
  }
  </code></pre>
  
  <p>The problem is that Typescript demands that the 'super' keyword appear first (literally) in the constructor implementation.  The specific build error message is:</p>
  
  <blockquote>
    <p>"A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."</p>
  </blockquote>
  
  <p>However, I need to determine which parameters I will pass into the 'super' (i.e. use a different constructor overload) based upon what was supplied to the extended (derived) class.  You should assume here that the derived class' constructor overloads may be very different from the super's.</p>
  
  <p>Is there a workaround for what I'm trying to achieve?</p>