<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="import Symbol from './Symbol';

export interface Iterable&lt;T&gt; {
    [Symbol.iterator](): Iterator&lt;T&gt;;
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-smi">Symbol</span> <span class="pl-k">from</span> <span class="pl-s">'./Symbol'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">interface</span> <span class="pl-smi">Iterable</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-kos">[</span><span class="pl-smi">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">iterator</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Iterator</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">In Dojo 2, <a href="https://github.com/dojo/core/blob/master/src/Symbol.ts#L164">we provide a shim for <code class="notranslate">Symbol</code></a>.  One of the things we have decided to do as a matter of principal is not modify the global namespace with any of our shims, but provide them as modules where the consumer has to make an explicit dependency on that shim.  At runtime, we offload to the native API if present, otherwise we provide replicate functionality.</p>
<p dir="auto">This pattern works effectively, even when targeting ES6, except for <code class="notranslate">Symbol</code> because of the TypeScript's compiler's insistence that we reference the native one.</p>
<p dir="auto">Is there a good reason why TypeScript disallows this when targeting ES6?  If so, is there any way to provide a transparent shim without modifying the global namespace anyone can think of?</p>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">No errors when targeting <code class="notranslate">es6</code>.</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">When target is <code class="notranslate">es6</code> we get the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'Symbol' reference does not refer to the global Symbol constructor object."><pre class="notranslate"><code class="notranslate">'Symbol' reference does not refer to the global Symbol constructor object.
</code></pre></div>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217)</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="// try augmenting the SymbolContructor to have some expected symbol on it.
// in RxJS5's case, it'll be the Symbol.observable symbol from the es-observable spec.
interface SymbolConstructor {
  observable: symbol;
}

interface Observablesque&lt;T&gt; {
  [Symbol.observable]: () =&gt; Subscribable&lt;T&gt;
}"><pre class="notranslate"><span class="pl-c">// try augmenting the SymbolContructor to have some expected symbol on it.</span>
<span class="pl-c">// in RxJS5's case, it'll be the Symbol.observable symbol from the es-observable spec.</span>
<span class="pl-k">interface</span> <span class="pl-smi">SymbolConstructor</span> <span class="pl-kos">{</span>
  <span class="pl-c1">observable</span>: <span class="pl-smi">symbol</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">Observablesque</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-kos">[</span><span class="pl-smi">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">observable</span><span class="pl-kos">]</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">Subscribable</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">or</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// try importing some symbol reference (I get why this might not work)
import {$$observable} from './symbol/observable';

interface Observablesque&lt;T&gt; {
  [$$observable]: () =&gt; Subscribable&lt;T&gt;
}"><pre class="notranslate"><span class="pl-c">// try importing some symbol reference (I get why this might not work)</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">$$observable</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./symbol/observable'</span><span class="pl-kos">;</span>

<span class="pl-k">interface</span> <span class="pl-smi">Observablesque</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-kos">[</span><span class="pl-s1">$$observable</span><span class="pl-kos">]</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">Subscribable</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">I should be able to enforce types that have symbols on them, custom or otherwise.</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">I get really confused and go get myself a coffee.</p>