@@ -5,6 +5,7 @@ import type {Paths} from './paths.d.ts';
55import type { Simplify } from './simplify.d.ts' ;
66import type { UnionToIntersection } from './union-to-intersection.d.ts' ;
77import type { UnknownArray } from './unknown-array.d.ts' ;
8+ import type { SimplifyDeep } from './simplify-deep.d.ts' ;
89
910/**
1011Pick properties from a deeply-nested object.
@@ -36,24 +37,15 @@ type Configuration = {
3637};
3738
3839type NameConfig = PickDeep<Configuration, 'userConfig.name'>;
39- // type NameConfig = {
40- // userConfig: {
41- // name: string;
42- // }
43- // };
40+ //=> {userConfig: {name: string}}
4441
4542// Supports optional properties
4643type User = PickDeep<PartialDeep<Configuration>, 'userConfig.name' | 'userConfig.age'>;
47- // type User = {
48- // userConfig?: {
49- // name?: string;
50- // age?: number;
51- // };
52- // };
44+ //=> {userConfig?: {name?: string; age?: number}}
5345
5446// Supports array
5547type AddressConfig = PickDeep<Configuration, 'userConfig.address.0'>;
56- // type AddressConfig = {
48+ //=> {
5749// userConfig: {
5850// address: [{
5951// city1: string;
@@ -64,14 +56,7 @@ type AddressConfig = PickDeep<Configuration, 'userConfig.address.0'>;
6456
6557// Supports recurse into array
6658type Street = PickDeep<Configuration, 'userConfig.address.1.street2'>;
67- // type Street = {
68- // userConfig: {
69- // address: [
70- // unknown,
71- // {street2: string}
72- // ];
73- // };
74- // }
59+ //=> {userConfig: {address: [unknown, {street2: string}] }}
7560```
7661
7762@category Object
@@ -86,7 +71,7 @@ export type PickDeep<T, PathUnion extends Paths<T>> =
8671 } [ PathUnion ]
8772 >
8873 : T extends object
89- ? Simplify < UnionToIntersection < {
74+ ? SimplifyDeep < UnionToIntersection < {
9075 [ P in PathUnion ] : InternalPickDeep < T , P > ;
9176 } [ PathUnion ] > >
9277 : never ;
0 commit comments