title: How to resolve Intersection and Union doesn't match in ts?
body: <p>I want to create a function that will create a different class by passing different args ,</p>
  <p>but I am getting an error in the code below；</p>
  <p>It looks like even though I specify the generic, typescript can't understand it</p>
  <pre class="lang-js prettyprint-override"><code>type ClassAOptions = {
    fooA: string;
    barA: string;
  };
  class ClassA {
    constructor(options: ClassAOptions) {}
  
    static new(options: ClassAOptions): ClassA {
      return new ClassA(options);
    }
  }
  
  type ClassBOptions = {
    fooB: boolean;
    barB: boolean;
  };
  class ClassB {
    constructor(options: ClassBOptions) {}
  
    static new(options: ClassBOptions): ClassB {
      return new ClassB(options);
    }
  }
  
  const classList = {
    first: ClassA,
    second: ClassB,
  };
  
  function createClass&lt;K extends keyof typeof classList&gt;(
    className: K,
    args: ConstructorParameters&lt;typeof classList[K]&gt;[0]
  ) {
    //  type error
    //  Argument of type 'ClassAOptions | ClassBOptions' is not assignable to parameter of type 'ClassAOptions &amp; ClassBOptions'.
    return new classList[className](-&gt;args&lt;-);
  }
  
  createClass(&quot;first&quot;, { fooA: &quot;false&quot;, barA: &quot;false&quot; });
  createClass(&quot;second&quot;, { fooB: false, barB: false });
  </code></pre>
  <p>this type error is make me crazy, does anyone know why typescript will show an error here,</p>
  <p>I can't find my answer on google at all;</p>
  <p>Or let me know the key point of this type err, I can google it then</p>