Skip to content

Instantly share code, notes, and snippets.

@Willmo36
Created August 4, 2020 15:44
Show Gist options
  • Select an option

  • Save Willmo36/0c1f506ad4822fb82273e60547f13259 to your computer and use it in GitHub Desktop.

Select an option

Save Willmo36/0c1f506ad4822fb82273e60547f13259 to your computer and use it in GitHub Desktop.
TypeScript union to intersection from FP slack
//Source: https://functionalprogramming.slack.com/archives/C7BBY9A95/p1594724501330700?thread_ts=1594687497.326100&cid=C7BBY9A95
type UnionToIntersection<U> =
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment