title: How do Object.freeze() and Readonly work in Typescript?
body: <p>Consider the following code:</p>
  
  <pre><code>class C {
    private x: string = "";
  }
  
  interface I {
    x: string;
  }
  
  const a: C = Object.freeze(new C()); // Error: Property 'x' is missing in type 'Readonly&lt;C&gt;' but required in type 'C'.
  const b: Readonly&lt;C&gt; = Object.freeze(new C());
  const c: I = Object.freeze(new C()); // Error: Property 'x' is missing in type 'Readonly&lt;C&gt;' but required in type 'I'.
  const d: I = Object.freeze({ x: "hi" });
  d.x = "foo";
  </code></pre>
  
  <p>Why do I get errors on those lines and not on the others? It almost makes sense that <code>Readonly&lt;T&gt;</code> is distinct from <code>T</code> and <code>Object.freeze()</code> returns <code>Readonly&lt;T&gt;</code>, except that the last two lines compile fine.</p>