title: undefined number (cast from string) getting past null check
body: <p>I've got a pretty simple situation that's got me puzzled. I'm passing a parameter to an express http get function. It's used in a query, so I'm making sure it's a number (and thus I'm safe from SQL injection).</p>
  
  <p>Due to my client data structure, I convert these numbers to strings. So I accidentally passed a string instead of a number. It caused my application to pass, as invoiceId evaluated to undefined, and the query failed.</p>
  
  <p>To protect against this, I have added a null check. Here's a working example (with some messing about so there's no compile error casting a string to a number):</p>
  
  <p>(Note, it was discovered the value was being passed as the string value "undefined", hence the confusion. I still have the issue of not being able to catch it as typescript forbids me from checking if invoiceId is a string value as it should be a number. I assumed <code>is</code> enforced type!)</p>
  
  <pre><code>class IBadInput { value: any };
  
  var badInput = { value: "undefined" } as IBadInput;
  var invoiceId = badInput.value as number;
  
  if (typeof invoiceId == 'undefined' || invoiceId == null)
  {
    console.log("inoice id not provided");
  }
  
  console.log("getting for invoice", invoiceId);
  </code></pre>
  
  <p>However, in the situation where a string invoiceId is provided, it doesn't not trigger the invoiceId == null statement. This is the output:</p>
  
  <pre><code>getting for invoice undefined
  </code></pre>
  
  <p>I've tried checking <code>invoiceId == undefined</code>, and <code>typeof invoiceId == null</code> just <code>if(invoiceId)</code> to check if it's "truthy" but everything get's passed this check.</p>
  
  <p>Any idea why, and how I can catch it?</p>