Created
March 26, 2019 20:39
-
-
Save sledorze/c69518d8caf0d5c5ef0a03cf9b4e2d1d to your computer and use it in GitHub Desktop.
ArrayElemIntersection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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