/** * See the definition of `@types/lodash`. */ type GetIndexedField = K extends keyof T ? T[K] : K extends `${number}` ? "length" extends keyof T ? number extends T["length"] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined; type FieldWithPossiblyUndefined = GetField, Key> | Extract; type IndexedFieldWithPossiblyUndefined = GetIndexedField, Key> | Extract; export type GetField = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude ? FieldWithPossiblyUndefined[Left], Right> | Extract : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined : undefined : IndexedFieldWithPossiblyUndefined; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K - The type of the key in the object. * @template D - The type of the default value. * * @param {T} object - The object to query. * @param {K | [K]} path - The path of the property to get. * @returns {T[K]} - Returns the resolved value. */ export declare function getField(object: T, path: K | readonly [K]): T[K]; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K - The type of the key in the object. * * @param {T | null | undefined} object - The object to query. * @param {K | [K]} path - The path of the property to get. * @returns {T[K] | undefined} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: K | readonly [K]): T[K] | undefined; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K - The type of the key in the object. * @template D - The type of the default value. * * @param {T | null | undefined} object - The object to query. * @param {K | [K]} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude | D} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: K | readonly [K], defaultValue: D): Exclude | D; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * * @param {T} object - The object to query. * @param {[K1, K2]} path - The path of the property to get. * @returns {T[K1][K2]} - Returns the resolved value. */ export declare function getField(object: T, path: readonly [K1, K2]): T[K1][K2]; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2]} path - The path of the property to get. * @returns {T[K1][K2] | undefined} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template D - The type of the default value. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2]} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude | D} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2], defaultValue: D): Exclude | D; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * * @param {T} object - The object to query. * @param {[K1, K2, K3]} path - The path of the property to get. * @returns {T[K1][K2][K3]} - Returns the resolved value. */ export declare function getField(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3]; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2, K3]} path - The path of the property to get. * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2, K3]): T[K1][K2][K3] | undefined; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * @template D - The type of the default value. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2, K3]} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude | D} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2, K3], defaultValue: D): Exclude | D; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * @template K4 - The type of the fourth key in the object. * * @param {T} object - The object to query. * @param {[K1, K2, K3, K4]} path - The path of the property to get. * @returns {T[K1][K2][K3][K4]} - Returns the resolved value. */ export declare function getField(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4]; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * @template K4 - The type of the fourth key in the object. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2, K3, K4]} path - The path of the property to get. * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template K1 - The type of the first key in the object. * @template K2 - The type of the second key in the object. * @template K3 - The type of the third key in the object. * @template K4 - The type of the fourth key in the object. * @template D - The type of the default value. * * @param {T | null | undefined} object - The object to query. * @param {[K1, K2, K3, K4]} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude | D} - Returns the resolved value. */ export declare function getField(object: T | null | undefined, path: readonly [K1, K2, K3, K4], defaultValue: D): Exclude | D; /** * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the value. * * @param {Record} object - The object to query. * @param {number} path - The path of the property to get. * @returns {T} - Returns the resolved value. */ export declare function getField(object: Record, path: number): T; /** * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the value. * * @param {Record | null | undefined} object - The object to query. * @param {number} path - The path of the property to get. * @returns {T | undefined} - Returns the resolved value. */ export declare function getField(object: Record | null | undefined, path: number): T | undefined; /** * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the value. * @template D - The type of the default value. * * @param {Record | null | undefined} object - The object to query. * @param {number} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {T | D} - Returns the resolved value. */ export declare function getField(object: Record | null | undefined, path: number, defaultValue: D): T | D; /** * Retrieves the value at a given path from a null or undefined object, returning the default value. * * @template D - The type of the default value. * * @param {null | undefined} object - The object to query. * @param {PropertyKey} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {D} - Returns the default value. */ export declare function getField(object: null | undefined, path: PropertyKey, defaultValue: D): D; /** * Retrieves the value at a given path from a null or undefined object, returning undefined. * * @param {null | undefined} object - The object to query. * @param {PropertyKey} path - The path of the property to get. * @returns {undefined} - Returns undefined. */ export declare function getField(object: null | undefined, path: PropertyKey): undefined; /** * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template P - The type of the path. * * @param {T} data - The object to query. * @param {P} path - The path of the property to get. * @returns {string extends P ? any : GetField} - Returns the resolved value. */ export declare function getField(data: T, path: P): string extends P ? any : GetField; /** * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead. * * @template T - The type of the object. * @template P - The type of the path. * @template D - The type of the default value. * * @param {T} data - The object to query. * @param {P} path - The path of the property to get. * @param {D} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude, null | undefined> | D} - Returns the resolved value. */ export declare function getField>(data: T, path: P, defaultValue: D): Exclude, null | undefined> | D; /** * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * * @param {unknown} object - The object to query. * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get. * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined. * @returns {any} - Returns the resolved value. */ export declare function getField(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any; export {};