Skip to content

Instantly share code, notes, and snippets.

@ultrox
Last active January 24, 2024 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ultrox/9031f9f9306caa07fbd2417e20ed012a to your computer and use it in GitHub Desktop.
Save ultrox/9031f9f9306caa07fbd2417e20ed012a to your computer and use it in GitHub Desktop.
Pretty Intersection
// 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