Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 1.04 KB

File metadata and controls

36 lines (26 loc) · 1.04 KB

Home > types-kit > DeepReplacePick

DeepReplacePick type

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

Example

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]>