<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217)</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class A{
    public static get foo(){
        return alert(&quot;should not execute getter, without accessing it !&quot;);
    }
}
class B extends A {}
"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">A</span><span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-k">static</span> <span class="pl-k">get</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s">"should not execute getter, without accessing it !"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-k">class</span> <span class="pl-smi">B</span> <span class="pl-k">extends</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">Should not alert message above</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">Alerting message above</p>
<p dir="auto">Link to <a href="http://www.typescriptlang.org/play/index.html#src=class%20A%7B%0D%0A%20%20%20%20public%20static%20get%20foo%28%29%7B%0D%0A%20%20%20%20%20%20%20%20return%20alert%28%22should%20not%20execute%20getter%2C%20without%20accessing%20it%20!%22%29%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0Aclass%20B%20extends%20A%20%7B%7D" rel="nofollow">Playground</a></p>
<p dir="auto">The following code:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var i = 0, j = 0;


class Base {
    get instanceAccessor() { return ++i; }
    static get staticAccessor() { return ++j; }
    toString = () =&gt; 'instance: ' + this.instanceAccessor + '   static: ' + Base.staticAccessor;
}


class Derived extends Base {
    toString = () =&gt; 'instance: ' + this.instanceAccessor + '   static: ' + Derived.staticAccessor;
}


console.log('Base:\n%s\n%s\n%s', new Base(), new Base(), new Base());
console.log('Derived:\n%s\n%s\n%s', new Derived(), new Derived(), new Derived());"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">j</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>


<span class="pl-k">class</span> <span class="pl-smi">Base</span> <span class="pl-kos">{</span>
    <span class="pl-k">get</span> <span class="pl-en">instanceAccessor</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-c1">++</span><span class="pl-s1">i</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
    <span class="pl-k">static</span> <span class="pl-k">get</span> <span class="pl-en">staticAccessor</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-c1">++</span><span class="pl-s1">j</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
    <span class="pl-c1">toString</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s">'instance: '</span> <span class="pl-c1">+</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">instanceAccessor</span> <span class="pl-c1">+</span> <span class="pl-s">'   static: '</span> <span class="pl-c1">+</span> <span class="pl-smi">Base</span><span class="pl-kos">.</span><span class="pl-c1">staticAccessor</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>


<span class="pl-k">class</span> <span class="pl-smi">Derived</span> <span class="pl-k">extends</span> <span class="pl-smi">Base</span> <span class="pl-kos">{</span>
    <span class="pl-c1">toString</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s">'instance: '</span> <span class="pl-c1">+</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">instanceAccessor</span> <span class="pl-c1">+</span> <span class="pl-s">'   static: '</span> <span class="pl-c1">+</span> <span class="pl-smi">Derived</span><span class="pl-kos">.</span><span class="pl-c1">staticAccessor</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>


<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Base:\n%s\n%s\n%s'</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Base</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Base</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Base</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Derived:\n%s\n%s\n%s'</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Derived</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Derived</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-smi">Derived</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">generates the following output (with the v1.3 compiler):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Base:
instance: 1   static: 2
instance: 2   static: 3
instance: 3   static: 4
Derived:
instance: 4   static: 1
instance: 5   static: 1
instance: 6   static: 1"><pre class="notranslate"><code class="notranslate">Base:
instance: 1   static: 2
instance: 2   static: 3
instance: 3   static: 4
Derived:
instance: 4   static: 1
instance: 5   static: 1
instance: 6   static: 1
</code></pre></div>
<p dir="auto">Clearly <code class="notranslate">Derived.staticAccessor</code> is no longer an accessor, but a 'snapshot' of the value of <code class="notranslate">Base.staticAccessor</code> when the <code class="notranslate">Derived</code> constructor function called <code class="notranslate">__extends</code>.</p>
<p dir="auto">Just wondering if this is the expected/correct behaviour?</p>
<p dir="auto">PS. I haven't run into this problem 'in the wild' as I rarely use classes or accessors, but merely came across a <a href="http://toshokelectric.com/blog/2013/04/04/why-im-ditching-coffeescript/" rel="nofollow">rant/blog post</a> about another compile-to-JS language doing something similar, and was curious how TypeScript handled it.</p>