import { List } from "../list"; import { UnionToIntersection } from "../set"; import { IsNever, Resolve, Unreachable } from "../type"; import { KeyPaths } from "./key-paths"; import { FromPath } from "./from-path"; import { DeepGet, Key } from "."; /** * constructs a single path */ type _PickPath> = Path extends any ? DeepGet extends infer V ? IsNever extends false ? FromPath> : never : Unreachable : Unreachable; /** * pick from O1 the keys defined in O2. * * does not account for property modifiers. * * all keys of the result are required. * i.e. if `O1 = { k?: V }`, then the result will have `{ k: V | undefined `}, * or however your typescript configuration handles optional properties. * * @since 0.0.9 * * @example * ```ts * type t0a = { a: { b: 0, c: 1 }, d: 4, e: 5 } * type t0b = { a: { b: 6 }, d: 7, z: 8 } * // { a: { b: 0; }; d: 4; } * type e0 = PickShape * * type t1a = { a: 1, b: { c: 2, d: {e: 3, f: 4 } }, g: 5, h: { i: 6, j: 7 } } * type t1b = { a: 9, b: { d: { f: 8 } }, h: 7, z: 6 } * // { a: 1; b: { d: { f: 4;};}; h: { i: 6; j: 7; };} * type e1 = PickShape * * type t2a = { a: { b?: 0, c: 1 }, d: 4, e: 5 } * type t2b = { a: { b: 6 }, d?: 7, z: 8 } * // { a: { b: 0 | undefined; }; d: 4; } * type e2 = PickShape * ``` */ export type PickShape = KeyPaths extends [infer Paths extends Key[], any] ? Resolve>> : never; export {}; //# sourceMappingURL=pick-shape.d.ts.map