types-kit.partialdeep.md

September 4, 2023 ยท View on GitHub

Home > types-kit > PartialDeep

PartialDeep type

Make all properties (includes deep properties) in T optional.

Signature:

export type PartialDeep<T> = {
  [P in keyof T]?: PartialDeep<T[P]>
}

References: PartialDeep

Example

interface Props {
      a: {
        d: number
      };
      b: number;
      c: number;
    };
   // Expect: { a?: { d?: number }; b?: number; c?: number; }
   type NewProps = PartialDeep<Props>;