Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 887 Bytes

File metadata and controls

39 lines (29 loc) · 887 Bytes

Home > types-kit > DeepValueOf

DeepValueOf type

Get deep values of T.

Signature:

export type DeepValueOf<T> = {
  [K in Keys<T>]: T[K] extends infer V
    ? V extends V
      ? IsObject<V> extends true
        ? T[K] | DeepValueOf<T[K]>
        : T[K]
      : never
    : never
}[Keys<T>]

References: Keys, IsObject, DeepValueOf

Example

 interface Props {
      a?: {
        d: () => void
      }
      b: string
      c: boolean
    }

 // Expect: { d: () => void } | (() => void) | string | boolean | undefined
 type PropValues = DeepValueOf<Props>