Last active
February 2, 2022 22:36
-
-
Save nwellis/98ccd528434d22b0edf34c4dd795a95c to your computer and use it in GitHub Desktop.
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
type ChildAndParent<TParent, TChild> = TParent extends string | |
? `${TParent}.${TChild extends string ? TChild : never}` | |
: TChild; | |
type DotNotation<T, TParent = false> = T extends object | |
? { [K in keyof T]: TParent | DotNotation<T[K], ChildAndParent<TParent, K>> }[keyof T] | |
: TParent | |
type Foo = DotNotation<{ | |
a: "hello" | |
b: "darkness" | |
c: { | |
d: "my" | |
e: "old" | |
f: { | |
g: "friend" | |
} | |
} | |
}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another @Beng89 💎