<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.9.0-dev.20160502</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="const xs = [1,2,3];
const ys = [4,5];
xs.push(...ys);"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">xs</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">,</span><span class="pl-c1">2</span><span class="pl-kos">,</span><span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">ys</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-c1">4</span><span class="pl-kos">,</span><span class="pl-c1">5</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">xs</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span>...<span class="pl-s1">ys</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Compiled with <code class="notranslate">tsc --target es6 --strictNullChecks test.ts</code></p>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">Compile without errors (without <code class="notranslate">--target es6</code> option, the code compiles successfully)</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">Errors are emitted:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test.ts(3,9): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'."><pre class="notranslate"><code class="notranslate">test.ts(3,9): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.
</code></pre></div>
<p dir="auto">Seems like values are treated nullable. (similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="151701758" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/8357" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/8357/hovercard" href="https://github.com/microsoft/TypeScript/issues/8357">#8357</a>)</p>
<p dir="auto">The variable in a for-of loop contains <code class="notranslate">undefined</code> when the target is set to es6. For es5, everything works as expected.</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">nightly (1.9.0-dev.20160428)</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="for (const x of [&quot;a&quot;, &quot;b&quot;]) {
    x.substring;
}"><pre class="notranslate"><span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">const</span> <span class="pl-s1">x</span> <span class="pl-k">of</span> <span class="pl-kos">[</span><span class="pl-s">"a"</span><span class="pl-kos">,</span> <span class="pl-s">"b"</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">x</span><span class="pl-kos">.</span><span class="pl-c1">substring</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">tsconfig.json:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;compilerOptions&quot;: {
        &quot;module&quot;: &quot;commonjs&quot;,
        &quot;target&quot;: &quot;es6&quot;,
        &quot;strictNullChecks&quot;: true
    }
}"><pre class="notranslate">{
    <span class="pl-ent">"compilerOptions"</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">"target"</span>: <span class="pl-s"><span class="pl-pds">"</span>es6<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"strictNullChecks"</span>: <span class="pl-c1">true</span>
    }
}</pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
Type of <code class="notranslate">x</code> is <code class="notranslate">string</code> in the loop body, no compile error.</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
Type of <code class="notranslate">x</code> is <code class="notranslate">string | undefined</code>, which gives an error.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ahejlsberg/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ahejlsberg">@ahejlsberg</a></p>