import type { Keys, Keys1, Keys2, Keys3, Keys4, Keys5, Keys6, Keys7, ValN } from "./keyval.js"; import type { Maybe } from "./null.js"; import type { NumOrString } from "./prim.js"; import type { Head, IsEmpty, Tail } from "./tuple.js"; /** * Unchecked lookup path for nested data structures. */ export type Path = readonly NumOrString[] | NumOrString; /** * Empty lookup path. */ export type Path0 = readonly []; /** * Type checked lookup path (depth 1) */ export type Path1 = A extends Keys ? readonly [A] : never; /** * Type checked lookup path (depth 2) */ export type Path2 = A extends Keys ? B extends Keys1 ? readonly [A, B] : never : never; /** * Type checked lookup path (depth 3) */ export type Path3 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? readonly [A, B, C] : never : never : never; /** * Type checked lookup path (depth 4) */ export type Path4 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? readonly [A, B, C, D] : never : never : never : never; /** * Type checked lookup path (depth 5) */ export type Path5 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? E extends Keys4 ? readonly [A, B, C, D, E] : never : never : never : never : never; /** * Type checked lookup path (depth 6) */ export type Path6 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? E extends Keys4 ? F extends Keys5 ? readonly [A, B, C, D, E, F] : never : never : never : never : never : never; /** * Type checked lookup path (depth 7) */ export type Path7 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? E extends Keys4 ? F extends Keys5 ? G extends Keys6 ? readonly [A, B, C, D, E, F, G] : never : never : never : never : never : never : never; /** * Type checked lookup path (depth 8) */ export type Path8 = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? E extends Keys4 ? F extends Keys5 ? G extends Keys6 ? H extends Keys7 ? readonly [A, B, C, D, E, F, G, H] : never : never : never : never : never : never : never : never; /** * Semi-typechecked lookup path (depth > 8). Only the first 8 levels are * checked. */ export type DeepPath = A extends Keys ? B extends Keys1 ? C extends Keys2 ? D extends Keys3 ? E extends Keys4 ? F extends Keys5 ? G extends Keys6 ? H extends Keys7 ? readonly [A, B, C, D, E, F, G, H, ...NumOrString[]] : never : never : never : never : never : never : never : never; /** * Returns `RES` if `PRED` is `never`, else `Maybe` */ export type OptVal = [PRED] extends [never] ? RES : Maybe; /** * Returns true if `T` includes undefined. */ export type IsOpt = T extends undefined ? true : never; /** * Internal recursive helper type for {@link IsOptPath}. */ type IsOptR = K extends Keys ? [true] extends [IsOpt] ? true : { 0: IsOptR[K], Head

, Tail

>; 1: never; }[IsEmpty

] : never; /** * Returns true if given path contains any intermediate properties * declared as optional in type `T`. * * Reference: * https://stackoverflow.com/q/60869412/294515 */ export type IsOptPath = P extends [] ? never : IsOptR, Tail

>; /** * Similar to {@link PathVal}, but also takes into account if given path * contains any intermediate properties declared as optional in type * `T`. If that's the case, returns union of `undefined` and inferred * value for path, else just the latter. * * Context & reference: https://stackoverflow.com/q/60869412/294515 */ export type OptPathVal = OptVal, ValN>; /** * Returns nested value type for given path into `T` or `never` if path * is incompatible with `T`. */ export type PathVal = ValN; export {}; //# sourceMappingURL=path.d.ts.map