ts-type-forge
    Preparing search index...

    Type Alias DeepPick<T, Path>

    DeepPick: {
        [K in keyof T as K extends DeepPickOmitHead<Path> ? K : never]: DeepPickValue<
            T[K],
            DeepPickOmitTail<Path, K>,
        >
    }

    Deeply picks a nested property from an object type along the specified key path. Supports union of paths to pick multiple nested properties. When one path is a prefix of another (e.g., ['a'] | ['a', 'b']), the shorter path takes precedence and the entire subtree is included.

    Type Parameters

    • T

      The object type to pick from.

    • Path extends readonly PropertyKey[]

      A tuple representing the key path, or a union of such tuples.

    A new object type containing only the properties along the specified path(s).

    type Data = { a: { b: { c: number; d: string } }; e: boolean };
    type Picked = DeepPick<Data, ['a', 'b', 'c']>;
    // Result: { a: { b: { c: number } } }

    type Multi = DeepPick<Data, ['a', 'b', 'c'] | ['e']>;
    // Result: { a: { b: { c: number } }; e: boolean }