<blockquote>
<p dir="auto">This is a suggestion for spec change.</p>
</blockquote>
<h3 dir="auto">Problem</h3>
<p dir="auto">Sometimes type's members could only be applicable with some restrictions of enclosing type parameter (generic type constraints).</p>
<p dir="auto">For instance, this is use case of RxJS:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var xs: Observable&lt;Observable&lt;string&gt;&gt;;
xs.mergeAll();  // mergeAll is applicable here

var ys: Observable&lt;string&gt;;
ys.mergeAll();  // mergeAll is NOT applicable here"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">xs</span>: <span class="pl-smi">Observable</span><span class="pl-kos">&lt;</span><span class="pl-smi">Observable</span><span class="pl-kos">&lt;</span><span class="pl-smi">string</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-s1">xs</span><span class="pl-kos">.</span><span class="pl-en">mergeAll</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>  <span class="pl-c">// mergeAll is applicable here</span>

<span class="pl-k">var</span> <span class="pl-s1">ys</span>: <span class="pl-smi">Observable</span><span class="pl-kos">&lt;</span><span class="pl-smi">string</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-s1">ys</span><span class="pl-kos">.</span><span class="pl-en">mergeAll</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>  <span class="pl-c">// mergeAll is NOT applicable here</span></pre></div>
<p dir="auto">Original Rx.NET <a href="http://msdn.microsoft.com/en-us/library/hh229740%28v=vs.103%29.aspx" rel="nofollow">Merge</a> method implemented as C# extension method on type <code class="notranslate">IObservable&lt;IObservable&lt;T&gt;&gt;</code>. In RxJS it's implemented as an instance method.</p>
<p dir="auto">Current RxJS typescript definition just use <a href="https://github.com/Reactive-Extensions/RxJS/blob/master/ts/rx-lite.d.ts#L258">unsafe trick</a>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export interface Observable&lt;T&gt; {
  ...
  mergeAll(): T;
  ...
}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">interface</span> <span class="pl-smi">Observable</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-c1">mergeAll</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">;</span>
  ...
<span class="pl-kos">}</span></pre></div>
<p dir="auto">But it can be still unsafely called for as instance of any <code class="notranslate">Observable&lt;T&gt;</code>.</p>
<h3 dir="auto">Possible solutions</h3>
<h4 dir="auto">Extension methods</h4>
<p dir="auto">Something like C# extension methods. But don't think it's useful in such cases.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare extensions {
  mergeAll&lt;T&gt;(this Observable&lt;Observable&lt;T&gt;&gt; source): Observable&lt;T&gt;;
}"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-s1">extensions</span> <span class="pl-kos">{</span>
  <span class="pl-c1">mergeAll</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-smi">this</span> <span class="pl-smi">Observable</span><span class="pl-c1">&lt;</span><span class="pl-smi">Observable</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;&gt;</span> <span class="pl-s1">source</span><span class="pl-kos">)</span>: <span class="pl-smi">Observable</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">BTW, extensions method could be other cool feature, which change call method (from instance-like to static-like).</p>
<h4 dir="auto">Multiple interface definitions with different constraints</h4>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface A&lt;T&gt; { x(): void; }
interface A&lt;T extends B&gt; { y(): void; }
var a: A&lt;number&gt;;
var b: A&lt;B&gt;;

a.x(); b.x(); // ok
b.y(); // ok
a.y(); // error"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">A</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-c1">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-k">interface</span> <span class="pl-smi">A</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span> <span class="pl-c1">y</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-k">var</span> <span class="pl-s1">a</span>: <span class="pl-smi">A</span><span class="pl-kos">&lt;</span><span class="pl-smi">number</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">b</span>: <span class="pl-smi">A</span><span class="pl-kos">&lt;</span><span class="pl-smi">B</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

<span class="pl-s1">a</span><span class="pl-kos">.</span><span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-s1">b</span><span class="pl-kos">.</span><span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// ok</span>
<span class="pl-s1">b</span><span class="pl-kos">.</span><span class="pl-en">y</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// ok</span>
<span class="pl-s1">a</span><span class="pl-kos">.</span><span class="pl-en">y</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// error</span></pre></div>
<h4 dir="auto">Member-level constraints with reference to enclosing type arguments</h4>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface A&lt;T&gt; {
  x(): void;
  y&lt;T extends B&gt;(): void; // only applicable if T extends B
  z&lt;T extends B&gt;: number; // for any property
  // alternative syntax options:
  &lt;T extends B&gt;z: number;  // 1

  z: number where T extends B;  // 2
  y(): void where T extends B;
}"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">A</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-c1">x</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
  <span class="pl-c1">y</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span> <span class="pl-c">// only applicable if T extends B</span>
  <span class="pl-c1">z</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-c1">&gt;</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span> <span class="pl-c">// for any property</span>
  <span class="pl-c">// alternative syntax options:</span>
  <span class="pl-c1">&lt;</span><span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-c1">&gt;</span><span class="pl-c1">z</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>  <span class="pl-c">// 1</span>

  <span class="pl-c1">z</span>: <span class="pl-smi">number</span> <span class="pl-s1">where</span> <span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-kos">;</span>  <span class="pl-c">// 2</span>
  <span class="pl-c1">y</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-s1">where</span> <span class="pl-smi">T</span> <span class="pl-k">extends</span> <span class="pl-smi">B</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">I'll suggest this option. Moreover the previous solution options is special case of this one (incompatible constraints are merged on member level).</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.10</p>
<h2 dir="auto">Inconsistencies:</h2>
<h3 dir="auto">1. The documentation for compiler options shows that you can set <code class="notranslate">module: "none"</code></h3>
<p dir="auto"><a href="http://www.typescriptlang.org/docs/handbook/compiler-options.html" rel="nofollow">http://www.typescriptlang.org/docs/handbook/compiler-options.html</a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/2856501/15205118/7e691a12-17c9-11e6-823b-f2ea0b56ea4f.png"><img src="https://cloud.githubusercontent.com/assets/2856501/15205118/7e691a12-17c9-11e6-823b-f2ea0b56ea4f.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This suggests that there should be an option to set <code class="notranslate">module: "none"</code> in a tsconfig.json file since it's equivalent to the <code class="notranslate">--module</code> flag.</p>
<h3 dir="auto">2. When editing the tsconfig.json file from within VS Code <code class="notranslate">"none"</code> is not an option for "module".</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/2856501/15205543/0e518e36-17cd-11e6-99b9-dfe6b1edbdbc.png"><img src="https://cloud.githubusercontent.com/assets/2856501/15205543/0e518e36-17cd-11e6-99b9-dfe6b1edbdbc.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This contradicts the documentation which says "none" is a valid option.</p>
<h3 dir="auto">3. If you create a new Asp.Net MVC project and add a typescript file and check the project settings you will in fact see that "None" is an option for module output and it outputs the variables as globals using IIFE pattern.</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/2856501/15205389/b1fcd1a0-17cb-11e6-8f5f-879495a9b4c8.png"><img src="https://cloud.githubusercontent.com/assets/2856501/15205389/b1fcd1a0-17cb-11e6-8f5f-879495a9b4c8.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This is confusing because the if you try to set module to none from VS code the typescript compiler will actually give an error:<br>
<code class="notranslate">error TS1148: Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file.</code></p>
<p dir="auto">This makes you wonder how it can be possible to set modules as None when in Visual Studio.</p>
<h2 dir="auto">How to compile to equivalent of <code class="notranslate">module: "none"</code></h2>
<p dir="auto">There might be a use case where someone wants to transpile to globals like visual studio does instead of being forced to use "amd", "commonjs", or "umd" and there isn't a clear way to do that in the <code class="notranslate">tsconfig.json</code> options.</p>
<p dir="auto">Is it true that VS code and Visual Studio are both using same compiler and should have the same features? (I know they could target different versions, but assuming they're not)</p>
<p dir="auto">I found that if you use a combination of:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="target: &quot;es5&quot;,
module: &quot;es2015&quot;
..."><pre class="notranslate"><code class="notranslate">target: "es5",
module: "es2015"
...
</code></pre></div>
<p dir="auto">It will show an error saying:<br>
<code class="notranslate">error TS1204: Cannot compile modules into 'es2015' when targeting 'ES5' or **lower.**</code><br>
but the output looks the closes to what <code class="notranslate">module: "none"</code> used to do.</p>
<h3 dir="auto">Resolution?</h3>
<p dir="auto">I would guess the easiest is to update tsconfig.json to allow <code class="notranslate">module: "none"</code> so it can be configured to behave the same as visual studio. Then it will also align with the documentation.</p>