<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">I use typescript compiler 1.8.10 from npm.</p>
<p dir="auto"><strong>Code</strong><br>
I use TypeScript in a project with ~500 ts files. When I type in console tsc -w and wait for the whole project is compiled, I add a small changes to one of my files. It re-compiles whole project instead of one changed file (it takes 10-25 seconds). I used node-inspector to track what the reason of such behavior. I found out that when it performs re-compilation (tsc.ts:564), it creates a new program without passing an old program as a forth parameter to the function.</p>
<p dir="auto">I created a small project for experiments with some files and start watcher with flag --listFiles:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="tsc -w --listFiles "><pre class="notranslate"><code class="notranslate">tsc -w --listFiles 
</code></pre></div>
<p dir="auto">My tsconfig.json:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;exclude&quot;: [],
  &quot;compilerOptions&quot;: {
    &quot;target&quot;: &quot;es5&quot;,
    &quot;module&quot;: &quot;commonjs&quot;,
    &quot;isolatedModules&quot;: true,
    &quot;declaration&quot;: false,
    &quot;inlineSourceMap&quot;: false,
    &quot;noImplicitAny&quot;: false,
    &quot;removeComments&quot;: true,
    &quot;noLib&quot;: false,
    &quot;allowJs&quot;: false
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"exclude"</span>: [],
  <span class="pl-ent">"compilerOptions"</span>: {
    <span class="pl-ent">"target"</span>: <span class="pl-s"><span class="pl-pds">"</span>es5<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"module"</span>: <span class="pl-s"><span class="pl-pds">"</span>commonjs<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"isolatedModules"</span>: <span class="pl-c1">true</span>,
    <span class="pl-ent">"declaration"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"inlineSourceMap"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"noImplicitAny"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"removeComments"</span>: <span class="pl-c1">true</span>,
    <span class="pl-ent">"noLib"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"allowJs"</span>: <span class="pl-c1">false</span>
  }
}</pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">It should compile only one changed file (I added a space to the calc.ts files).</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">It re-compiles whole files:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/891497/15356025/e1afc71c-1cfe-11e6-8816-305bc4d7b9be.png"><img src="https://cloud.githubusercontent.com/assets/891497/15356025/e1afc71c-1cfe-11e6-8816-305bc4d7b9be.png" alt="1" style="max-width: 100%;"></a></p>
<p dir="auto">I understand that such behavior can't be added for project that should be bundled into one file.</p>
<p dir="auto">Thanks</p>
<p dir="auto">The constructs:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let v = v;
const c = c;"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">v</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s1">c</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">should error because they are uses before definition. Indeed IE gives this error.</p>
<p dir="auto">This also applies to:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="for (let v = v; ; ) { }
for (let v in v) { }
for (let v of v) { }"><pre class="notranslate"><span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">v</span><span class="pl-kos">;</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">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">v</span> <span class="pl-k">in</span> <span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>
<span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">v</span> <span class="pl-k">of</span> <span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span></pre></div>
<p dir="auto">For the latter two in particular, look at section 13.6.4.12 in the ES6 spec:</p>
<ol dir="auto">
<li>
<p dir="auto">Let oldEnv be the running execution context’s LexicalEnvironment.</p>
</li>
<li>
<p dir="auto">If TDZnames is not an empty List, then</p>
<p dir="auto">a. Assert: TDZnames has no duplicate entries.<br>
b. Let TDZ be NewDeclarativeEnvironment(oldEnv).<br>
c. For each string name in TDZnames, do</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  i. Let status be TDZ.CreateMutableBinding(name, false).
  ii. Assert: status is never an abrupt completion."><pre class="notranslate"><code class="notranslate">  i. Let status be TDZ.CreateMutableBinding(name, false).
  ii. Assert: status is never an abrupt completion.
</code></pre></div>
<p dir="auto">d. Set the running execution context’s LexicalEnvironment to TDZ.</p>
</li>
<li>
<p dir="auto">Let exprRef be the result of evaluating the production that is expr.</p>
</li>
<li>
<p dir="auto">Set the running execution context’s LexicalEnvironment to oldEnv.</p>
</li>
</ol>