Skip to content

Instantly share code, notes, and snippets.

@sledorze
Created March 26, 2019 20:39
Show Gist options
  • Save sledorze/c69518d8caf0d5c5ef0a03cf9b4e2d1d to your computer and use it in GitHub Desktop.
Save sledorze/c69518d8caf0d5c5ef0a03cf9b4e2d1d to your computer and use it in GitHub Desktop.
ArrayElemIntersection
type ArrayElemIntersection<T extends any[]> = ({ [k in keyof T]: (x: T[k]) => void })[number] extends (
a: infer A
) => any
? A
: never
// Example
type A = [{ x: '5' }, { y: '8' }]
type IntersectAs = ArrayElemIntersection<A> // { x: '5' } & { y: '8' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment