Immutable data in TypeScript
<p>PLOT:</p>

<p>I have a protected variable named <code>myVar</code> and it is structure and data is defined by the constructor such as </p>

<pre><code>this.myVar = this.legacy ? this.legacy.listing : this.default;
</code></pre>

<p>When you edit <code>myVar</code> it also change <code>this.default</code> structure and data. So my problem is simple : how would you keep <code>this.default</code> immutable ?</p>

<p>Any help appreciated,</p>

<p>PS: functions such as </p>

<pre><code>private default = (): Structure[] =&gt; {
  return [{
    param1: 'param1'
  }]
}
</code></pre>

<p>is not what I aim.</p>