title: Build own assert class
body: <p>I would like to create my own little assertion class. I tried to install mocha and chai, but got lots and lots of errors from deep within those modules, so for the moment I'd rather try something self-built, if not at least to learn more TypeScript.</p>
  
  <p>I found a good template (<a href="https://gist.github.com/brunolm/6031927" rel="nofollow noreferrer">https://gist.github.com/brunolm/6031927</a>) of a class, and the implementations for IsFalse, IsTrue, AreEqual work just fine. I extended it for my needs with an IsNullOrUndefined, all good so far.</p>
  
  <p>I would also like to use the IsInstanceOf test. It is implemented like this:</p>
  
  <pre><code>public static IsInstanceOfType(expectedType: Function, actual: any): void {
      if (!(actual instanceof expectedType)) {
          // some more code to construct a message, and throw
      }
  }
  </code></pre>
  
  <p>I cannot get that code to work though. I do not know how / what to pass as first argument. I try like this</p>
  
  <pre><code>Assert.IsInstanceOfType((): List&lt;string&gt; =&gt; { return undefined; }, list);
  </code></pre>
  
  <p>with List&lt;> being my own generic collection class, and list being an instance of it (or not... that's to find out).</p>
  
  <p>The code above compiles, but fails the assertion fails even when it should not. I find the "pass a function that returns the type you expect" strange, and would prefer something nicer, if possible.
  If this is the way to go, then I am using it wrong - how would you use it?</p>
  
  <p>I asked the author, and he suggest I should call like this</p>
  
  <pre><code>Assert.IsInstanceOfType(List&lt;string&gt;, list);
  </code></pre>
  
  <p>but that does not go through with the compiler, that can't be right, or is it? I cannot get it to work - that is the type written out, not a function?!?</p>
  
  <p>Any suggestion?</p>