@augment-vir/common 21.3.2 → 21.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { AnyFunction } from '../function';
|
|
2
|
+
import { ArrayElement } from '../type';
|
|
2
3
|
import { NestedKeys } from './nested-keys';
|
|
3
|
-
type InnerPickDeep<OriginalObjectGeneric
|
|
4
|
-
|
|
4
|
+
type InnerPickDeep<OriginalObjectGeneric, DeepKeys extends any[]> = DeepKeys extends [
|
|
5
|
+
infer CurrentLevelPick,
|
|
6
|
+
...infer RemainingKeys
|
|
7
|
+
] ? {
|
|
8
|
+
[CurrentProp in Extract<CurrentLevelPick, keyof OriginalObjectGeneric>]: AnyFunction extends Extract<OriginalObjectGeneric[CurrentProp], AnyFunction> ? OriginalObjectGeneric[CurrentProp] | Exclude<OriginalObjectGeneric[CurrentProp], AnyFunction> : Array<any> extends Extract<OriginalObjectGeneric[CurrentProp], Array<any>> ? Array<InnerPickDeep<ArrayElement<Extract<OriginalObjectGeneric[CurrentProp], Array<any>>>, RemainingKeys>> | Exclude<OriginalObjectGeneric[CurrentProp], Array<any>> : ReadonlyArray<any> extends Extract<OriginalObjectGeneric[CurrentProp], ReadonlyArray<any>> ? ReadonlyArray<InnerPickDeep<ArrayElement<Extract<OriginalObjectGeneric[CurrentProp], ReadonlyArray<any>>>, RemainingKeys>> | Exclude<OriginalObjectGeneric[CurrentProp], ReadonlyArray<any>> : Extract<OriginalObjectGeneric[CurrentProp], Record<any, any>> extends never ? OriginalObjectGeneric[CurrentProp] : InnerPickDeep<Extract<OriginalObjectGeneric[CurrentProp], Record<any, any>>, RemainingKeys>;
|
|
5
9
|
} : DeepKeys extends [] ? OriginalObjectGeneric : DeepKeys extends [infer CurrentLevelPick] ? CurrentLevelPick extends keyof OriginalObjectGeneric ? Pick<OriginalObjectGeneric, CurrentLevelPick> : never : never;
|
|
6
10
|
/**
|
|
7
11
|
* Pick nested keys with more strict type parameter requirements. However, these stricter type
|