Created
July 13, 2022 06:20
-
-
Save gustavohenke/826359a784235c17bb3643d841dbec40 to your computer and use it in GitHub Desktop.
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
/** | |
* Recursively unions the types of the properties of T. | |
* TODO: Deal with arrays | |
* | |
* @example | |
* type SomeObject = { a: { b: { c: boolean } }, d: string }; | |
* const x: DeepUnion<SomeObject>; // boolean | string | |
*/ | |
type DeepUnion<T extends object> = { | |
[K in keyof T]: T[K] extends object ? DeepValues<T[K]> : T[K]; | |
}[keyof T]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment