devtypes - v2.0.0
    Preparing search index...

    Type Alias ChainMapped<K, T>

    ChainMapped: K extends [infer F extends string, ...(infer R extends string[])]
        ? { [K in F]: ChainMapped<R, T> }
        : T

    Nest an object structure based on a list of keys.

    Type Parameters

    • K extends string[]

      A tuple of string keys representing the nesting levels

    • T

      The type to assign at the deepest level

    Will recursively create nested objects for each key in the list, assigning the final type T at the deepest level.

    Note that if no keys are provided, this turns into < K, T > => T

    type RestaurantMenu = ChainMapped< [ 'night' | 'day', 'entry' | 'main' | 'dessert' ], () => void >
    // {
    // night: { entry: () => void; main: () => void; dessert: () => void };
    // day: { entry: () => void; main: () => void; dessert: () => void };
    // }