Created
April 20, 2023 17:59
-
-
Save webstrand/2e1b18479c39761227087a79e36444da to your computer and use it in GitHub Desktop.
Recursively generate a list of all paths into some object
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
type StringSerialized<T extends object, Prefix extends string = ""> = T extends Array<any> ? { | |
[P in keyof T & `${bigint}`]: `-${P}` extends `${bigint}` | |
? | `${Prefix}${P}` | |
| StringSerialized<T[P] & object, `${Prefix}${P}.`> | |
: never | |
}[keyof T & `${bigint}`] : { | |
[P in keyof T & string]: | |
| `${Prefix}${P}` | |
| StringSerialized<T[P] & object, `${Prefix}${P}.`> | |
}[keyof T & string]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment