Go to repository

Type Alias Leaves<T>

Leaves<T>: T extends object
    ? {
        [K in keyof T]: `${Exclude<K, symbol>}${Leaves<T[K]> extends never
            ? ""
            : `.${Leaves<T[K]>}`}`
    }[keyof T]
    : never

This type represent all the possible leaves of an object type.

Type Parameters

  • T

A leaf consists of a path that leads ultimately to a simple value. So for example let' say we have an object with the form { foo: { bar: 5, baz: 'hello' } }, then the Leaves of it's type are foo.bar and foo.baz.

This type is useful if you need to type things such as paths in an object that lead to a particular value, such as the types of a translation in a json file.