@augment-vir/common
Version:
A collection of augments, helpers types, functions, and classes for any JavaScript environment.
18 lines (17 loc) • 1.03 kB
TypeScript
import { type AnyObject } from '@augment-vir/core';
/**
* Gets the type of a nested property within `Parent` by recursively accessing each key in `Keys`.
*
* @category Object
* @category Package : @augment-vir/common
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export type DeepValue<Parent extends AnyObject, Keys extends ReadonlyArray<PropertyKey>> = Keys extends Readonly<[infer First, ...infer Rest]> ? First extends keyof Parent ? Rest extends ReadonlyArray<PropertyKey> ? DeepValue<Parent[First], Rest> : undefined : undefined : Parent;
/**
* Gets the value of a nested property within `Parent` by recursively accessing each key in `Keys`.
*
* @category Object
* @category Package : @augment-vir/common
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare function getDeepValue<const Parent extends AnyObject, const Keys extends ReadonlyArray<PropertyKey>>(parent: Parent, keys: Readonly<Keys>): DeepValue<Parent, Keys>;