title: How to implement TypeScript deep partial mapped type not breaking array properties
body: <p>Any ideas as to how might apply TypeScript's Partial mapped type to an interface recursively, at the same time not breaking any keys with array return types?</p>
  
  <p>The following approaches have not been sufficing:  </p>
  
  <pre><code>interface User {  
    emailAddress: string;  
    verification: {
      verified: boolean;
      verificationCode: string;
    }
    activeApps: string[];
  }
  
  type PartialUser = Partial&lt;User&gt;; // does not affect properties of verification  
  
  type PartialUser2 = DeepPartial&lt;User&gt;; // breaks activeApps' array return type;
  
  export type DeepPartial&lt;T&gt; = {
    [ P in keyof T ]?: DeepPartial&lt;T[ P ]&gt;;
  }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>UPDATE:
  Accepted answer - A better and more general solve for now.</p>
  
  <p>Had found a temporary workaround which involves intersection of types and two mapped types as follows. The most notable drawback is that you have to supply the property overrides to restore sullied keys, the ones with array return types.</p>
  
  <p>E.g.</p>
  
  <pre><code>type PartialDeep&lt;T&gt; = {
    [ P in keyof T ]?: PartialDeep&lt;T[ P ]&gt;;
  }
  type PartialRestoreArrays&lt;K&gt; = {
    [ P in keyof K ]?: K[ P ];
  }
  
  export type DeepPartial&lt;T, K&gt; = PartialDeep&lt;T&gt; &amp; PartialRestoreArrays&lt;K&gt;;
  
  interface User {  
   emailAddress: string;  
   verification: {
     verified: boolean;
     verificationCode: string;
   }
   activeApps: string[];
  }
  
  export type AddDetailsPartialed = DeepPartial&lt;User, {
   activeApps?: string[];
  }&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tqqDB.png" rel="noreferrer">Like so</a></p>