<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.10</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 a=false;
if  (a) {
    console.log('should be unreachable');
}"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">a</span><span class="pl-c1">=</span><span class="pl-c1">false</span><span class="pl-kos">;</span>
<span class="pl-k">if</span>  <span class="pl-kos">(</span><span class="pl-s1">a</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-s">'should be unreachable'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><a href="http://www.typescriptlang.org/play/#src=const%20a%3Dfalse%3B%0D%0Aif%20%20%28a%29%20%7B%0D%0A%09console.log%28'should%20be%20unreachable'%29%3B%0D%0A%7D%0D%0A" rel="nofollow">TypeScript Play</a><br>
<strong>Expected behavior:</strong><br>
The code should be unreachable in fact that a is immutable. A warning should be placed<br>
<strong>Actual behavior:</strong><br>
No unreachable warning.</p>
<h1 dir="auto">Proposal</h1>
<p dir="auto">I know that it could be a little bit difficult to check if we check a property of an object. But for primititves it should work. the compiler already knows if it is a constant and did not allow them to assign twice.</p>
<p dir="auto">Allow duplicated members in multiple interface declarations, as long as they are identical. Optional compiling warnings are acceptable, to assist developers to remove redundant codes at convenient time.</p>
<p dir="auto">This should not generate any errors, example:</p>
<p dir="auto">shim.d.ts</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface Symbol {
    toString(): string;
    valueOf(): Object;
    [Symbol.toStringTag]: string;
}"><pre class="notranslate"><span class="pl-s1">interface</span> <span class="pl-v">Symbol</span> <span class="pl-kos">{</span>
    <span class="pl-c1">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>
    <span class="pl-en">valueOf</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-v">Object</span><span class="pl-kos">;</span>
    <span class="pl-kos">[</span><span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">toStringTag</span><span class="pl-kos">]</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">es6.d.ts</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="...
interface Symbol {
    /** Returns a string representation of an object. */
    toString(): string;

    /** Returns the primitive value of the specified object. */
    valueOf(): Object;

    [Symbol.toStringTag]: string;
}
..."><pre class="notranslate">...
<span class="pl-s1">interface</span> <span class="pl-v">Symbol</span> <span class="pl-kos">{</span>
    <span class="pl-c">/** Returns a string representation of an object. */</span>
    <span class="pl-c1">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/** Returns the primitive value of the specified object. */</span>
    <span class="pl-en">valueOf</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-v">Object</span><span class="pl-kos">;</span>

    <span class="pl-kos">[</span><span class="pl-v">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">toStringTag</span><span class="pl-kos">]</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
...</pre></div>