<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.5</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="declare type ConstrainedString = &quot;La première&quot; | &quot;La primera&quot; | &quot;The first&quot;;

function f(s : ConstrainedString) {
    console.log(s);
}

f(&quot;La primera&quot;);
f(&quot;La première&quot;);
f(&quot;The first&quot;);


f(&quot;De eerste&quot;); // Error message is here, as expected."><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">type</span> <span class="pl-smi">ConstrainedString</span> <span class="pl-c1">=</span> <span class="pl-s">"La première"</span> <span class="pl-c1">|</span> <span class="pl-s">"La primera"</span> <span class="pl-c1">|</span> <span class="pl-s">"The first"</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s1">s</span> : <span class="pl-smi">ConstrainedString</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">s</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s">"La primera"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s">"La première"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s">"The first"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>


<span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-s">"De eerste"</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Error message is here, as expected.</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">The second sentence of the error message I see under Visual Studio Code doesn't seem to make sense, does it?<br>
<code class="notranslate">Argument of type '"De eerste"' is not assignable to parameter or type '"La première" | "La primera" | "The first"'. Type '"De eerste"' is not assignable to type "The first"'</code></p>
<p dir="auto">I wonder if I should not rather open this under VS Code.</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
Removing that second sentence?</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface A {
    a: number
}
interface B {
    b: number
}
interface C {
    c: number
}
interface D {
    d: number
}
declare var c: C;
let abc: ((A | B) &amp; C) | D = c;"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-c1">a</span>: <span class="pl-smi">number</span>
<span class="pl-kos">}</span>
<span class="pl-k">interface</span> <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-c1">b</span>: <span class="pl-smi">number</span>
<span class="pl-kos">}</span>
<span class="pl-k">interface</span> <span class="pl-smi">C</span> <span class="pl-kos">{</span>
    <span class="pl-c1">c</span>: <span class="pl-smi">number</span>
<span class="pl-kos">}</span>
<span class="pl-k">interface</span> <span class="pl-smi">D</span> <span class="pl-kos">{</span>
    <span class="pl-c1">d</span>: <span class="pl-smi">number</span>
<span class="pl-kos">}</span>
<span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">c</span>: <span class="pl-smi">C</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">abc</span>: <span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-smi">A</span> <span class="pl-c1">|</span> <span class="pl-smi">B</span><span class="pl-kos">)</span> <span class="pl-c1">&amp;</span> <span class="pl-smi">C</span><span class="pl-kos">)</span> <span class="pl-c1">|</span> <span class="pl-smi">D</span> <span class="pl-c1">=</span> <span class="pl-s1">c</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Actual error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Type 'C' is not assignable to type '((A | B) &amp; C) | D'.
  Type 'C' is not assignable to type 'D'.
    ...."><pre class="notranslate"><code class="notranslate">Type 'C' is not assignable to type '((A | B) &amp; C) | D'.
  Type 'C' is not assignable to type 'D'.
    ....
</code></pre></div>
<p dir="auto">Expected error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Type 'C' is not assignable to any branch of the union type '((A | B) &amp; C) | D'.
  For example, type 'C' is not assignable to type 'D'.
    ...."><pre class="notranslate"><code class="notranslate">Type 'C' is not assignable to any branch of the union type '((A | B) &amp; C) | D'.
  For example, type 'C' is not assignable to type 'D'.
    ....
</code></pre></div>
<p dir="auto">Error reporting on unions doesn't mention that the compiler tried to assign the source to all branches of the target. Instead it proceeds to elaborate just the last branch's error. It should make it clear that the error elaboration is just one of several checks that failed.</p>
<p dir="auto">Otherwise it is easy to assume that the compiler <em>only</em> tried the last branch and somehow skipped the "more promising" branch (which ultimately also fails, but at least contains the source type).</p>
<p dir="auto">Based on one of the multiple issues reported by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Aleksey-Bykov/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Aleksey-Bykov">@Aleksey-Bykov</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="127548825" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/6538" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/6538/hovercard" href="https://github.com/microsoft/TypeScript/issues/6538">#6538</a>.</p>