<p dir="auto"><strong>TypeScript Version:</strong><br>
1.8.0-1.8.7</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="import {Key} from 'types'; // Key is an interface
const Key = { test() {} };
Key.test();
export default Key;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-smi">Key</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'types'</span><span class="pl-kos">;</span> <span class="pl-c">// Key is an interface</span>
<span class="pl-k">const</span> <span class="pl-smi">Key</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-en">test</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-kos">;</span>
<span class="pl-smi">Key</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-smi">Key</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Key.test();
exports.default = Key;"><pre class="notranslate"><span class="pl-smi">Key</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">default</span> <span class="pl-c1">=</span> <span class="pl-smi">Key</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Actual behavior:</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="types_1.Key.test();
exports.default = types_1.Key;"><pre class="notranslate"><span class="pl-s1">types_1</span><span class="pl-kos">.</span><span class="pl-c1">Key</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">default</span> <span class="pl-c1">=</span> <span class="pl-s1">types_1</span><span class="pl-kos">.</span><span class="pl-c1">Key</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">It is incredibly easy to make a copy/paste error for <code class="notranslate">case</code> clauses in a <code class="notranslate">switch</code> statement.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="switch (node.kind) {
    // ...
    case SyntaxKind.TupleType:
        // Do something with tuple types.
    case SyntaxKind.TupleType:
        // Do something with union types.
    // ...
}"><pre class="notranslate"><span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-s1">node</span><span class="pl-kos">.</span><span class="pl-c1">kind</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-c">// ...</span>
    <span class="pl-k">case</span> <span class="pl-smi">SyntaxKind</span><span class="pl-kos">.</span><span class="pl-c1">TupleType</span>:
        <span class="pl-c">// Do something with tuple types.</span>
    <span class="pl-k">case</span> <span class="pl-smi">SyntaxKind</span><span class="pl-kos">.</span><span class="pl-c1">TupleType</span>:
        <span class="pl-c">// Do something with union types.</span>
    <span class="pl-c">// ...</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">While it is easily arguable that non-exhaustive cases can be allowed in TypeScript, there is no reason not to report duplicated cases.</p>
<p dir="auto">"Obvious" semantics for <code class="notranslate">case</code> clauses in a single <code class="notranslate">switch</code> statement are as follows:</p>
<ul dir="auto">
<li>Report when named entities with identical symbols are handled.</li>
<li>Report when equal string literals are handled.</li>
<li>Report when equal numeric literals (even 0.0 and 0) are handled.</li>
<li>Report when <code class="notranslate">null</code> is handled more than once.</li>
<li>Report when <code class="notranslate">undefined</code> is handled more than once.</li>
</ul>
<hr>
<p dir="auto"><del>One interesting question is whether exhaustive cases for an enum should report an error when there is a <code class="notranslate">default</code> clause.</del></p>