<p dir="auto">Example:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Class1 {
    private privateMember;
}

class Class2 implements Class1 {
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Class1</span> <span class="pl-kos">{</span>
    <span class="pl-k">private</span> <span class="pl-c1">privateMember</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Class2</span> <span class="pl-k">implements</span> <span class="pl-smi">Class1</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">The compiler says:<br>
<code class="notranslate">Property 'privateMember' is missing in type 'Class2'</code></p>
<p dir="auto">But obviusly a private member never will be part of an interface.</p>
<p dir="auto">Hi, we have a requirement to create mocks of real classes defined in code. The exact requirements are</p>
<ul dir="auto">
<li>A specific mock should define the public API of the real class.</li>
<li>If the public API of the real class changes in any way then the compiler should detect the corresponding breakage in the mock class.</li>
</ul>
<p dir="auto">A possible solution might be as follows:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare var fileWriter: any; 

// Real class
class Foo {

    public writeToFile(){
        fileWriter.writeToFile('');
    }
}

// Mock
class MockFoo implements Foo {

     public writeToFile(){
         // do nothing
     }
}"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">fileWriter</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span> 

<span class="pl-c">// Real class</span>
<span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>

    <span class="pl-k">public</span> <span class="pl-en">writeToFile</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
        <span class="pl-s1">fileWriter</span><span class="pl-kos">.</span><span class="pl-en">writeToFile</span><span class="pl-kos">(</span><span class="pl-s">''</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-c">// Mock</span>
<span class="pl-k">class</span> <span class="pl-smi">MockFoo</span> <span class="pl-k">implements</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>

     <span class="pl-k">public</span> <span class="pl-en">writeToFile</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
         <span class="pl-c">// do nothing</span>
     <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This appears to solve the problem because changing <code class="notranslate">Foo.writeToFile</code> will trigger a compilation error along the lines of "Class MockFoo declares interface Foo but does not implement it..."</p>
<p dir="auto">The problem with this approach is that <code class="notranslate">class Foo</code> is not permitted to have any private methods or fields. If we were to add a private method <code class="notranslate">foo()</code> to <code class="notranslate">class Foo</code> then it's no longer possible for <code class="notranslate">MockFoo</code> to implement <code class="notranslate">Foo</code> because the compiler doesn't permit it.</p>
<p dir="auto">I suggest that when a class implements another class the implementing class be allowed to ignore the private fields and methods (both static and instance) of the implementee.</p>
<p dir="auto">(I am aware that there are workarounds, such as declaring an interface that both <code class="notranslate">Foo</code> and <code class="notranslate">MockFoo</code> implement, but that introduces an unnecessary maintenance overhead.)</p>