main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import { Key } from '../Any/Key';
|
---|
2 | import { NonNullableFlat } from '../Object/NonNullable';
|
---|
3 | import { Cast } from '../Any/Cast';
|
---|
4 | import { List } from '../List/List';
|
---|
5 | import { BuiltIn } from '../Misc/BuiltIn';
|
---|
6 | import { Primitive } from '../Misc/Primitive';
|
---|
7 | import { Length } from '../List/Length';
|
---|
8 | import { Keys } from '../Any/Keys';
|
---|
9 | /**
|
---|
10 | * @hidden
|
---|
11 | */
|
---|
12 | declare type UnionOf<A> = A extends List ? A[number] : A[keyof A];
|
---|
13 | /**
|
---|
14 | * @hidden
|
---|
15 | */
|
---|
16 | declare type _Paths<O, P extends List = []> = UnionOf<{
|
---|
17 | [K in keyof O]: O[K] extends BuiltIn | Primitive ? NonNullableFlat<[...P, K?]> : [
|
---|
18 | Keys<O[K]>
|
---|
19 | ] extends [never] ? NonNullableFlat<[...P, K?]> : 12 extends Length<P> ? NonNullableFlat<[...P, K?]> : _Paths<O[K], [...P, K?]>;
|
---|
20 | }>;
|
---|
21 | /**
|
---|
22 | * Get all the possible paths of `O`
|
---|
23 | * (⚠️ this won't work with circular-refs)
|
---|
24 | * @param O to be inspected
|
---|
25 | * @returns [[String]][]
|
---|
26 | * @example
|
---|
27 | * ```ts
|
---|
28 | * ```
|
---|
29 | */
|
---|
30 | export declare type Paths<O, P extends List = []> = _Paths<O, P> extends infer X ? Cast<X, List<Key>> : never;
|
---|
31 | export {};
|
---|
Note:
See
TracBrowser
for help on using the repository browser.