title: Check if variable belongs to custom type in Typescript
body: <p>I'm trying to check whether a variable belongs to a certain type or not. </p>
  
  <p>Code:</p>
  
  <pre><code>type GeneralType = SubTypeA | SubTypeB;
  type SubTypeA = 'type1' | 'type2';
  type SubTypeB = 'type3' | 'type4';
  
  function someFunction(arg1: GeneralType) {
    if (arg1 instanceof SubTypeA) {
      // Do something
    }
    // Continue function
    return arg1;
  }
  </code></pre>
  
  <p>Of course this code fails in line 6 because <code>instanceof</code> is not usable for types. Is there an alternative option I could use without needing to check explicitly every posible value for <code>SubTypeA</code>?</p>