<p dir="auto">Hello! See example</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type lang = &quot;en&quot; | &quot;ru&quot;;
function getDict(lng: lang): any {
    switch (lng) {
        case 'ru':
            return ru;
        case 'stringNotInLangType':
            return en;
    }
}"><pre class="notranslate"><span class="pl-s1">type</span> <span class="pl-s1">lang</span> <span class="pl-c1">=</span> <span class="pl-s">"en"</span> <span class="pl-c1">|</span> <span class="pl-s">"ru"</span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-en">getDict</span><span class="pl-kos">(</span><span class="pl-s1">lng</span>: <span class="pl-s1">lang</span><span class="pl-kos">)</span>: <span class="pl-s1">any</span> <span class="pl-kos">{</span>
    <span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-s1">lng</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">case</span> <span class="pl-s">'ru'</span>:
            <span class="pl-k">return</span> <span class="pl-s1">ru</span><span class="pl-kos">;</span>
        <span class="pl-k">case</span> <span class="pl-s">'stringNotInLangType'</span>:
            <span class="pl-k">return</span> <span class="pl-s1">en</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">compiler should throw error, cause</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" case 'stringNotInLangType':
            return en;"><pre class="notranslate"> <span class="pl-s1">case</span> <span class="pl-s">'stringNotInLangType'</span>:
            <span class="pl-k">return</span> <span class="pl-s1">en</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">is unreachable</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type foo = 'hey' | 'nay';

switch (&lt;foo&gt;undefined) {
    case 'boom': console.log('never the case'); break; // expected unreachable code, actual no problem
}"><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">foo</span> <span class="pl-c1">=</span> <span class="pl-s">'hey'</span> <span class="pl-c1">|</span> <span class="pl-s">'nay'</span><span class="pl-kos">;</span>

<span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-kos">&lt;</span><span class="pl-smi">foo</span><span class="pl-kos">&gt;</span><span class="pl-c1">undefined</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-s">'boom'</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-s">'never the case'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-k">break</span><span class="pl-kos">;</span> <span class="pl-c">// expected unreachable code, actual no problem</span>
<span class="pl-kos">}</span></pre></div>