Is there are way to use ghost classes in typescript?
<p>I always encounter problems when trying to use 'legacy' <code>JavaScript</code> code from within <code>TypeScript 2.0</code> code. </p>

<p>This is in spite of knowing that you need a type definition file <code>(*.d.ts)</code> for doing that and reading the 'best pratice' articles <a href="https://typescript.codeplex.com/wikipage?title=Writing%20Definition%20%28.d.ts%29%20Files" rel="nofollow noreferrer">Writing Definition Files</a> and <a href="http://definitelytyped.org/guides/best-practices.html" rel="nofollow noreferrer">Best Practices</a>. </p>

<p>My current problem is that I want to use <code>TypeScript</code> in a <code>React/Alt</code> application. The <code>TypeScript</code> compiler is configured to directly emit es5 code for the browser (i.e. "target": "es5" in tsconfig.json).</p>

<p>The problematic part is converting a Action js file to ts.</p>

<p>I followed the <a href="https://github.com/goatslacker/alt/blob/master/docs/typescript.md" rel="nofollow noreferrer">Alt recommendations to doing that</a>. The example there is the following: </p>

<pre><code>/**AltJS is a "ghost module" full of non-instantiable interfaces and typedefs to help you write easier code
 * included in our alt.d.ts type definitions
 */

class AbstractActions implements AltJS.ActionsClass {
 constructor( alt:AltJS.Alt){}
 actions:any;
 dispatch: ( ...payload:Array&lt;any&gt;) =&gt; void;
 generateActions:( ...actions:Array&lt;string&gt;) =&gt; void;
}

//This class will now compile!!
class SomeCoolActions extends AbstractActions {
 constructor() {
     this.generateActions(
         "firstAction",
         "secondAction",
         "thirdAction",
         "fourthAction
     );
 }
}
</code></pre>

<p>The problem with this example is that it will compile <em>but it will not work</em>. When trying I always get the following error message in the browser:</p>

<blockquote>
  <p>Uncaught ReferenceError: AbstractActions is not defined(…)</p>
</blockquote>

<p>The reason for that is obvious as well: <code>AbstractActions</code> is an (abstract) <strong>Ghost class</strong>, i.e. it is only there to make the typescript compiler happy. In the Alt module there is no such thing called <code>AbstractActions</code>. All the magic that makes <code>generateActions</code> work is from the <code>Alt.createActions</code> factory:</p>

<pre><code>let someCoolActions = alt.createActions&lt;Actions&gt;(SomeCoolActions);
</code></pre>

<p>Hence here are my questions:</p>

<ol>
<li><p>Is there a way to repair this, i.e. use an <code>AbstractActions</code> ghost class for making TypeScript happy but have a 'dummy' implementation to keep the browser happy as well?</p></li>
<li><p>More general: Is there a way to ensure that the (legacy) JS implementation of a module I define a type definition (*.d.ts) for, is present when the browser executes the JS app?</p></li>
</ol>