KiaraGrouwstra / typical

playground for type-level primitives in TypeScript
MIT License
173 stars 5 forks source link

UnionToIntersection #28

Closed ccorcos closed 5 years ago

ccorcos commented 5 years ago

I use this library all the time for reference but I couldn't find this type in here:

https://stackoverflow.com/questions/56213182/how-to-merge-the-properties-of-all-objects-in-a-union-type/56213252

type UnionToIntersection<U> =
    (U extends any ? (k: U) => void : never) extends
    ((k: infer I) => void) ? I : never
KiaraGrouwstra commented 5 years ago

this? :sweat_smile: would you expect it to be in intersection rather than union?

ccorcos commented 5 years ago

Lol. I couldn't find it! I think intersection was the word that I was unaware of. I was thinking in my head something called MergeUnion. Is intersection the name for the & operator?

KiaraGrouwstra commented 5 years ago

hahaha. I think so yeah! :)