Home > types-kit > DeepReplacePick
Create a type that replace the values in the corresponding deep keys.
Signature:
export type DeepReplacePick<
T,
KeysArr extends readonly DeepKeys<T>[],
ValuesArr extends Fill<KeysArr['length'], unknown>,
> = InternalDeepReplacePick<T, KeysArr, ValuesArr>References: DeepKeys, Fill, InternalDeepReplacePick
interface Props {
readonly a?: {
d?: boolean
}
b?: number
c: number
}
// Expect: { readonly a?: { d?: string }, b?: number, c: string }
// ['a.d','c'] means the keys to replace, [string, string] means the values to map
type new Props = DeepReplacePick<Props, ['a.d','c'], [string, string]>