title: Typescript Union To Intersection returns values as never
body: <p>My question is with reference to this post</p>
  
  <p><a href="https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type">Transform union type to intersection type</a></p>
  
  <p>Whenever i convert a union To Intersection i loose the union type, here is some code i wrote to get around the issue </p>
  
  <pre><code>type SomeUnion = 'A' | 'B';
  
  
  type UnionToIntersection&lt;U&gt; = (U extends any ? (k: U) =&gt; void : never) extends ((k: infer I) =&gt; void) ? I : never
  
  type UnionToInterSectionWoNever&lt;T&gt; = {
    [K in keyof UnionToIntersection&lt;T&gt;]: UnionToIntersection&lt;T&gt;[K] extends never ? T[K] : UnionToIntersection&lt;T&gt;[K]
  };
  
  
  type UnionDistribution&lt;T&gt; = T extends SomeUnion ?
    { unionType: T } &amp; (
      T extends 'A' ? { aProp1: string, aProp2: number } :
      T extends 'B' ? { bProp1: string } : never) :
    never;
  
  type ABUnion = UnionDistribution&lt;SomeUnion&gt;;
  
  type ABInterSection = UnionToIntersection&lt;ABUnion&gt;;
  
  type ABInterSectionWoNever = UnionToInterSectionWoNever&lt;ABUnion&gt;;
  
  // This in infered as never;
  type ABInterSectionUnionType = ABInterSection['unionType'];
  
  // This in inferred as 'A' | 'B'
  type ABInterSectionWoNeverUnionType = ABInterSectionWoNever['unionType'];
  </code></pre>
  
  <p>So i am not 100% confident of the code, it would be really helpful to have a second thought on the same.
  I'm curios when something like this will fail and how to resolve the same.</p>
  
  <p>Thanks in Advance.</p>