TypeScript: extending existing JavaScript object
<p>I have a pure JavaScript object (let's call it O) from a certain library, with its interface in an ambient namespace, e.g.:</p>

<pre><code>declare namespace N {
    interface IO {
        // properties...
    }
}
</code></pre>

<p>I need to create a TypeScript class, which will extend this JavaScript object. The mechanism for extending it is provided by the library, so I cannot use the native TS inheritance, yet I need to have access to all the properties of this JS object, which I'm extending. I tried declaring a class which implements this interface and extending it:</p>

<pre><code>declare class DummyO implements N.IO {
    // copy-paste everything from N.IO
}

class MyRealClass extends DummyO {
}
</code></pre>

<p>Now I have access to all the properties, but also two problems:</p>

<ol>
<li>I had to copy-paste the whole interface, which is not so practical.</li>
<li>TypeScript doesn't create any definition for DummyO (which is good), but in the same time tries to extend it using its native mechanism (which is bad, since DummyO doesn't really exist).</li>
</ol>

<p>So the question is - how to work around it? How to create a TS class, which effectively extends this native object? Or maybe there's another way to convince TS that I'm really inheriting O without all that hassle?</p>