Type Alias PathsOf<T>

PathsOf: T extends object
    ? {
        [K in keyof T]-?: K extends string
        | number
            ? `${K}` | `${K}.${PathsOf<T[K]>}`
            : never
    }[keyof T]
    : never

The union of all dot-separated paths in an object rescursively.

Here's an illustration:

type Obj = { a: { b: { c: string } } };

type ObjPaths = PathsOf<Obj>;
// ^? type ObjPaths = "a" | "a.b" | "a.b.c"

Type Parameters

  • T

    the object to get paths from.