Type alias LeafNodes<Target>

LeafNodes<Target>: Target extends unknown[]
    ? ""
    : Target extends object
        ? ArrayToUnion<_LeafNodes<UnionToArray<Branches<Target>>>>
        : ""

LeafNodes

Type Parameters

  • Target

Desc

Get all possible leaf nodes of an object in dot notation, skipping the intermediate branches

Oaram

Target - The object to get the leaf nodes of

Returns

A union of strings

Example

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'