How to stub a Typescript-Interface / Type-definition?
<p>I work with Typescript on an AngularJS 1.X project. I use different Javascript libraries for different purposes. To unit-test my source I would like to stub some dependencies using the Typings (= interfaces). I don't want to use the ANY-type and neither to write an empty method for each interface method.</p>

<p>Im looking for a way to do something like that:</p>

<pre><code>let dependency = stub(IDependency);
stub(dependency.b(), () =&gt; {console.log("Hello World")});
dependency.a(); // --&gt; Compile, do nothing, no exception
dependency.b(); // --&gt; Compile, print "Hello World", no exception
</code></pre>

<p>The pain I have right now, is that I either use <code>any</code> and implement all methods which get called in my test case or I implement the interface and implement the full interface. That's too much useless code :(.</p>

<p>How can I generate an object that has an empty implementation for each method and is typed? I use Sinon for mocking purposes, but im open to use other libraries too.</p>

<p>PS: I know that Typescript erases the interfaces...but I still would like to solve that :).</p>