Created
May 8, 2023 09:28
-
-
Save z0gSh1u/c62afb14cc5237eb4e9532755a0bddc2 to your computer and use it in GitHub Desktop.
Full expand TypeScript type
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
| // 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