Get all possible leaf nodes of an object in dot notation, skipping the intermediate branches
Target - The object to get the leaf nodes of
A union of strings
type Sample = {
a: string;
b: {
c: string;
d?: {
e?: string;
f: Array<{
g: string;
h: {
i?: string;
};
}>;
};
};
}
type Result = Branches<Sample>; // 'a' | 'b.c' | 'b.d.e' | 'b.d.f[number].g' | 'b.d.f[number].h.i'
LeafNodes