title: Typescript - How to determine the real non-primitive type of an union parameter in a construcotr?
body: <p>I have two classes and a enum:</p>
  <pre><code>abstract class Base {
    protected constructor(method: EnumMethod) {
      ...
    }
  }
  
  class Leaf {
    constructor(method: EnumMethod) {
       super(method);
    }
  }
  
  enum EnumMethod {
    CARD = 'card',
    APPLEPAY = 'applePay',
    GOOGLEPAY  = 'googlePay',
  }
  </code></pre>
  <p>Then, I want the <code>Leaf</code> class can accept more options while the old codes passing in EumMethod directly still can work, so I create an interface for it:</p>
  <pre><code>interface Params {
    method: EnumMethod;
    foo: string;
    bar: number;
  }
  </code></pre>
  <p>Then I find I don't know how to determine the parameter in constructor. What I want to do is:</p>
  <pre><code>class Leaf {
    constructor(params: EnumMethod | Params) {
       super(params is EnumMethod ? params : params.method);
    }
  }
  </code></pre>
  <p>How can I implement the <code>is</code> operator in TypeScript?</p>