Get all possible branches of an object in dot & bracket notation
All possible branches of the object
type Sample = {
a: string;
b: {
c: string;
d?: {
e?: string;
f: Array<{
g: string;
h: {
i?: string;
};
}>;
};
};
}
type Result = Branches<Sample>; // 'a' | 'b' | 'b.c' | 'b.d' | 'b.d.e' | 'b.d.f' | 'b.d.f[number].g' | 'b.d.f[number].h' | 'b.d.f[number].h.i'
Branches