Last active
January 24, 2024 10:11
-
-
Save ultrox/9031f9f9306caa07fbd2417e20ed012a to your computer and use it in GitHub Desktop.
Pretty Intersection
This file contains hidden or 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
// Simple | |
type Prettify<T> = { | |
[K in keyof T]: T[K] | |
} & {} | |
// Recursive | |
type Prettify<T> = T extends {} ? { | |
[K in keyof T]: Prettify<T[K]> | |
} & {} : T | |
// https://twitter.com/Riyaadh_Abr/status/1622736576303312899/photo/1 | |
type ExpandRecursively<T> | |
= T extends Record<string, unknown> | Record<string, unknown>[] | |
? T extends infer 0 | |
? { [K in keyof 0]: ExpandRecursively<o[K]> } | |
: never | |
: T; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment