Skip to content

Instantly share code, notes, and snippets.

@z0gSh1u
Created May 8, 2023 09:28
Show Gist options
  • Select an option

  • Save z0gSh1u/c62afb14cc5237eb4e9532755a0bddc2 to your computer and use it in GitHub Desktop.

Select an option

Save z0gSh1u/c62afb14cc5237eb4e9532755a0bddc2 to your computer and use it in GitHub Desktop.
Full expand TypeScript type
// https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type
// expands object types one level deep
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
// expands object types recursively
type ExpandRecursively<T> = T extends object
? T extends infer O ? { [K in keyof O]: ExpandRecursively<O[K]> } : never
: T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment