import { Key } from '../Any/Key'; import { Head } from '../List/Head'; import { List } from '../List/List'; import { Pop } from '../List/Pop'; import { Tail } from '../List/Tail'; import { Path } from '../Object/Path'; import { UnionOf } from '../Object/UnionOf'; import { Select } from '../Union/Select'; import { Join } from '../String/Join'; import { Split } from '../String/Split'; /** * @ignore */ declare type Index = number | string; /** * @ignore */ declare type KeyToIndex> = number extends K ? Head : K & Index; /** * @ignore */ declare type MetaPath = [], P extends List = []> = { [K in keyof O]: MetaPath, [...P, KeyToIndex]> | Join<[...P, KeyToIndex], D>; }; /** * @ignore */ declare type NextPath = Select & {}>, string>; /** * @ignore */ declare type ExecPath, Delimiter extends string> = NextPath, SP>>; /** * @ignore */ declare type HintPath, Exec extends string, D extends string> = [Exec] extends [never] ? ExecPath, D> : Exec | P; /** * @ignore */ declare type _AutoPath = Split> = HintPath, D>; /** * Auto-complete, validate, and query the string path of an object `O` * @param O to work on * @param P path of `O` * @param D (?=`'.'`) delimiter for path * * ```ts * declare function get( * object: O, path: AutoPath * ): Path> * * declare const user: User * * type User = { * name: string * friends: User[] * } * * // works * const friendName = get(user, 'friends.40.name') * const friendFriendName = get(user, 'friends.40.friends.12.name') * * // errors * const friendNames = get(user, 'friends.40.names') * const friendFriendNames = get(user, 'friends.40.friends.12.names') * ``` */ export declare type AutoPath = _AutoPath; export {};