title: DeepReadonly Object Typescript
body: <p>It is possible to create a <code>DeepReadonly</code> type like this:</p>
  
  <pre><code>type DeepReadonly&lt;T&gt; = {
    readonly [P in keyof T]: DeepReadonly&lt;T[P]&gt;;
  };
  
  interface A {
    B: { C: number; };
    D: { E: number; }[];
  }
  
  const myDeepReadonlyObject: DeepReadonly&lt;A&gt; = {
    B: { C: 1 },
    D: [ { E: 2 } ],
  }
  
  myDeepReadonlyObject.B = { C: 2 }; // error :)
  myDeepReadonlyObject.B.C = 2; // error :)
  </code></pre>
  
  <p>This is great. Both <code>B</code> and <code>B.C</code> are readonly. When I try to modify <code>D</code> however...</p>
  
  <pre><code>// I'd like this to be an error
  myDeepReadonlyObject.D[0] = { E: 3 }; // no error :(
  </code></pre>
  
  <p>How should I write <code>DeepReadonly</code> so that nested arrays are readonly as well?</p>