Skip to content
Typeutilsv0.8.17

PathToObj

Converts a dot-notation path string into a nested object type with a specific leaf value. hasKeys builds its narrowed type out of these.

type PathToObj<
    Path extends string,
    Value
> = Path extends `${infer Head}.${infer Tail}`
    ? { [K in Head]: PathToObj<Tail, Value> }
    : { [K in Path]: Value };

Value

Value