title: TypeScript - Is there an option to disallow using "! in front of anything except a boolean?
body: <p>I understand this may be a classical javascript issue, but I too often found myself using :</p>
  
  <pre><code>if (!something) {
      //...
  }
  </code></pre>
  
  <p>to validate that this <code>something</code> is not <code>undefined</code> or <code>null</code>, in TypeScript.</p>
  
  <p>This is very error-prone! When used on a <code>number</code> "0" will match, and when used on an <code>enum</code> the first item will match too (by default, the first item has a value of "0")!</p>
  
  <p>Is there a way to deal with this in TypeScript? Is there a way to configure TypeScript to disallow an exclamation mark in front of anything except a <code>boolean</code> (and <code>any</code>)? Would this configuration make sense or am I missing something trivial?</p>
  
  <p>Should :</p>
  
  <pre><code>if (something === null || something === undefined) {
      //...
  }
  </code></pre>
  
  <p>be used instead, to validate that something is defined or not? And is there a way to enforce this in a team?</p>