title: Usages of "readonly" in TypeScript
body: <h1>Usage 1: a function declares its parameter won't be modified</h1>
  
  <p>This usage is very simple: as a contract, the function <code>doSomething</code> declares it doesn't mutate the received parameter.</p>
  
  <pre><code>interface Counter {
    name: string
    value: number
  }
  
  function doSomething(c: Readonly&lt;Counter&gt;) {
    // ...
  }
  
  let c = {
    name: "abc",
    value: 123
  }
  doSomething(c)
  // Here we are sure that 'c.name' is "abc" and 'c.value' is '123'
  </code></pre>
  
  <h1>Usage 2: a factory declares that its output cannot be modified</h1>
  
  <p>With this code:</p>
  
  <pre><code>interface Counter {
    readonly name: string
    readonly value: number
    inc(): number
  }
  
  function counterFactory(name: string): Counter {
    let value = 0
    return {
      get name() {
        return name
      },
      get value() {
        return value
      },
      inc() {
        return ++value
      }
    }
  }
  </code></pre>
  
  <p>We have here a member <code>readonly value</code> that cannot be modified directly from the outside. But a member <code>inc()</code> can mutate the value. Also, the member <code>value</code> is declared as <code>readonly</code> but its value is changing.</p>
  
  <p>I would like to know if this use of <code>readonly</code> on the member <code>value</code> is a good way to proceed. The syntax is OK. But is this example semantically correct in TypeScript? Is that what the modifier <code>readonly</code> is for?</p>