1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 19:04:46 +00:00

refactor(packages/stdlib): change getByPath type to string and add comments to template types

This commit is contained in:
2024-05-30 02:51:08 +07:00
parent ba68e293b9
commit d0c74be856
3 changed files with 33 additions and 13 deletions

View File

@@ -44,7 +44,7 @@ type Path<T> = T extends `${infer Key}.${infer Rest}`
// Output: { a: { b: { c: PropertyKey } } }
export type UnionToIntersection<Union> = (
Union extends unknown
Union extends unknown
? (distributedUnion: Union) => void
: never
) extends ((mergedIntersection: infer Intersection) => void)
@@ -62,7 +62,7 @@ type PathToType<T extends string[]> = T extends [infer Head, ...infer Rest]
? { [K in Head & string]: PathToType<Rest> }
: never
: never
: unknown;
: string;
export type Generate<T extends string> = UnionToIntersection<PathToType<Path<T>>>;
type Get<O, K> = GetWithArray<O, Path<K>>;