Variant have problems and inconvenient to use. One problem, many functions need 
just the single variant, but you had to pass the all variants, and end up with 
lots of unneded check like `variant.kind == 'a'` etc. And some other problems.
    
    
    // With union types
    interface A {}
    function a(arg: A) {}
    
    interface B {}
    function b(arg: B) {}
    
    function ab(arg: A | B) {}
    
    
    Run
    
    
    // Variant
    interface A {}
    interface B {}
    type VariantAB = A | B
    
    function a(arg: VariantAB) { // You don't need B here, but there's no way 
to avoid it
      if (arg instanceof A) { // <= And so you had to check if it's A
        ...
      }
    }
    
    
    Run

Reply via email to