<p dir="auto">When 'this' is used as type it is replaced with the following interface or class.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class A {
 f(a : this) {} // &lt;=&gt; f(a : A)
 g(x : any) { 
   if (x instanceof this) { } // &lt;=&gt; x instanceof A
}

interface B {
  x : this; // &lt;=&gt; x : B
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
 <span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s1">a</span> : this<span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-c">// &lt;=&gt; f(a : A)</span>
 <span class="pl-en">g</span><span class="pl-kos">(</span><span class="pl-s1">x</span> : <span class="pl-smi">any</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> 
   <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">x</span> <span class="pl-k">instanceof</span> <span class="pl-smi">this</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span> <span class="pl-c">// &lt;=&gt; x instanceof A</span>
<span class="pl-kos">}</span>

<span class="pl-c1">interface</span> <span class="pl-smi">B</span> <span class="pl-kos">{</span>
  <span class="pl-c1">x</span> : this<span class="pl-kos">;</span> <span class="pl-c">// &lt;=&gt; x : B</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">The early discussions about generics had this feature outlined, but it never made it into the final version for some reason. Meanwhile, it would be extremely helpful in some cases. The use case that it most dear to my heart is Knockout:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="interface Observable&lt;T&gt; {
   &lt;U&gt;( this: U, value: T ): U;
}

var viewModel = {
   Str: ko.observable( &quot;abc&quot; ),
   Num: ko.observable( 5 )
};

viewModel.Str( &quot;xyz&quot; ).Num( 10 );"><pre class="notranslate"><code class="notranslate">interface Observable&lt;T&gt; {
   &lt;U&gt;( this: U, value: T ): U;
}

var viewModel = {
   Str: ko.observable( "abc" ),
   Num: ko.observable( 5 )
};

viewModel.Str( "xyz" ).Num( 10 );
</code></pre></div>