<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.2 and Nigtly</p>
<p dir="auto"><strong>Code</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="private _appendScript (): void {
            this._script = this._createScriptElement();
            console.log(1, this); // pointed on class object

            let scripts = document.getElementsByTagName('script');
            console.log(2, this); // pointed on class object

            for (let script in scripts) {
                console.log(3, this);  // pointed on Window
            }

            // same with
            //for (let i = 0, len = scripts.length; i &lt; len; i++) {
            //    console.log(4, this);  // pointed on Window
            //}
        }"><pre class="notranslate"><code class="notranslate">private _appendScript (): void {
            this._script = this._createScriptElement();
            console.log(1, this); // pointed on class object

            let scripts = document.getElementsByTagName('script');
            console.log(2, this); // pointed on class object

            for (let script in scripts) {
                console.log(3, this);  // pointed on Window
            }

            // same with
            //for (let i = 0, len = scripts.length; i &lt; len; i++) {
            //    console.log(4, this);  // pointed on Window
            //}
        }
</code></pre></div>
<p dir="auto">full class code<br>
<a href="https://gist.github.com/sanex3339/3efa99e0817d30bb0803#file-wrong-this-capture-L73">https://gist.github.com/sanex3339/3efa99e0817d30bb0803#file-wrong-this-capture-L73</a></p>
<p dir="auto">Important note - wrong <code class="notranslate">this</code> capture occurs only in this place, in other classes everythink ok.</p>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto"><code class="notranslate">this</code> inside for loops must pointed on class object</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
<code class="notranslate">this</code> inside for loops is pointed on <code class="notranslate">Window</code></p>
<p dir="auto">There have been a few cases reported by customers that using <code class="notranslate">--watch</code> has been on the slow side. We should elicit feedback to understand what's going on.</p>
<p dir="auto">Examples:</p>
<ul dir="auto">
<li><a href="https://www.reddit.com/r/typescript/comments/48rzzq/protip_what_to_do_to_solve_the_current_slowness/" rel="nofollow">https://www.reddit.com/r/typescript/comments/48rzzq/protip_what_to_do_to_solve_the_current_slowness/</a></li>
<li><a href="https://gitter.im/Microsoft/TypeScript?at=56d86d9906ba9a282a28ecf1" rel="nofollow">https://gitter.im/Microsoft/TypeScript?at=56d86d9906ba9a282a28ecf1</a></li>
</ul>