title: Typescript: Can't return child class instance from super class' function
body: <p>I'm having trouble returning a child class object from a super class function. I have the following structure:</p>
  <p><strong>pizza.ts:</strong></p>
  <pre><code>import { PineapplePizza } from './pineapple.pizza';
  
  export class Pizza {
      public putOn(Pineapple pineapple): Pizza {
          // ...
          return new PineapplePizza(pineapple);
          // ...
      }
  }
  </code></pre>
  <p><strong>pineapple.pizza.ts:</strong></p>
  <pre><code>import { Pizza } from './pizza';
  
  export class PineapplePizza extends Pizza {
      // ...
  }
  </code></pre>
  <p>But I keep getting this runtime error:</p>
  <p><strong>firefox:</strong></p>
  <blockquote>
  <p>ReferenceError: can't access lexical declaration 'Pizza' before initialization</p>
  </blockquote>
  <p><strong>chrome:</strong></p>
  <blockquote>
  <p>ReferenceError: 'Pizza' is not defined</p>
  </blockquote>
  <p>Does anyone know how to fix that? Or is impossible to return a child class instance from a super class?</p>
  <p><strong>EDIT #1:</strong></p>
  <p>This might be due to circular importing. Is there a way to pre-declare a class, kind of like with <code>c++</code>? Or a way to control which file gets compiled first?</p>