title: typescript - detect if function exists on a type
body: <p>I am writing <code>mocha</code> tests.</p>
  <p>I have 2 interfaces(<code>TestInterface1, TestInterface2</code>). They have functions described on it such as:</p>
  <ul>
  <li><code>TestInterface1</code> - <code>Func1, Func2</code></li>
  <li><code>TestInterface2</code> - <code>Func1, Func2, Func3</code></li>
  </ul>
  <p>In my tests, I have a class <code>Test</code> that sometimes ends up to be of <code>TestInterface1</code> but might still have a function <code>Func3</code>. It's like in run-time, can't decide which interface it belongs to.</p>
  <p>Let's say it ended up to be <code>TestInterface1</code>. Now, it still could have <code>Func3</code>, but because of the interface, when I call function, it says that Function doesn't exist even though it does.  How can I still figure out that <code>Func3</code> still exists on the <code>Test</code> which is of <code>TestInterface1</code> ?</p>