<p dir="auto">I am trying to work on 5 Minute quick start tutorial for Angular 2. (<a href="https://angular.io/docs/ts/latest/quickstart.html" rel="nofollow">https://angular.io/docs/ts/latest/quickstart.html</a>). While executing npm install I am getting following errors with typings. I was getting similar errors for es6-shim, but got that resolved after setting http and https_proxy variables.</p>
<p dir="auto">Any pointer to resolve this issue?</p>
<p dir="auto">typings ERR! message Unable to read typings for "jasmine". You should check the entry paths in "jasmine.d.ts" are up to date<br>
typings ERR! caused by Unable to connect to "<a href="https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/jasmine/jasmine.d.ts" rel="nofollow">https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/jasmine/jasmine.d.ts</a>"<br>
typings ERR! caused by self signed certificate in certificate chain</p>
<p dir="auto">typings ERR! cwd C:\Learning\Angular\a2\angular2-quickstart<br>
typings ERR! system Windows_NT 6.1.7601<br>
typings ERR! command "C:\Program Files\nodejs\node.exe" "C:\Learning\Angular\a2\angular2-quickstart\node_modules\typings\dist\bin.js" "install"<br>
typings ERR! node -v v4.4.0<br>
typings ERR! typings -v 0.7.12</p>
<p dir="auto">typings ERR! If you need help, you may report this error at:<br>
typings ERR!   <a href="https://github.com/typings/typings/issues">https://github.com/typings/typings/issues</a></p>
<p dir="auto">npm ERR! Windows_NT 6.1.7601<br>
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"<br>
npm ERR! node v4.4.0<br>
npm ERR! npm  v2.14.20<br>
npm ERR! code ELIFECYCLE<br>
npm ERR! angular2-quickstart@1.0.0 postinstall: <code class="notranslate">typings install</code><br>
npm ERR! Exit status 1<br>
npm ERR!<br>
npm ERR! Failed at the angular2-quickstart@1.0.0 postinstall script 'typings install'.<br>
npm ERR! This is most likely a problem with the angular2-quickstart package,<br>
npm ERR! not with npm itself.<br>
npm ERR! Tell the author that this fails on your system:<br>
npm ERR!     typings install<br>
npm ERR! You can get information on how to open an issue for this project with:<br>
npm ERR!     npm bugs angular2-quickstart<br>
npm ERR! Or if that isn't available, you can get their info via:<br>
npm ERR!<br>
npm ERR!     npm owner ls angular2-quickstart<br>
npm ERR! There is likely additional logging output above.</p>

<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="// A self-contained demonstration of the problem follows...
"><pre class="notranslate"><span class="pl-c">// A self-contained demonstration of the problem follows...</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">This is a refinement of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="39067312" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/306" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/306/hovercard" href="https://github.com/microsoft/TypeScript/issues/306">#306</a>, which I believe shows a missed opportunity for eliding import declarations from generated code, as well as a problematic consequence of the current behaviour.</p>
<p dir="auto">Suppose we have the file <code class="notranslate">code.ts</code> containing:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare module A {
    export enum Color { Red=1, Green=2, Blue=3 }
}

module B {
    import Color = A.Color;
}

import Color = A.Color;"><pre class="notranslate"><span class="pl-k">declare</span> module <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-k">enum</span> <span class="pl-smi">Color</span> <span class="pl-kos">{</span> <span class="pl-c1">Red</span><span class="pl-c1">=</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">Green</span><span class="pl-c1">=</span><span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-c1">Blue</span><span class="pl-c1">=</span><span class="pl-c1">3</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

module <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">then tsc.exe generates the following in <code class="notranslate">code.js</code>:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var B;
(function (B) {
})(B || (B = {}));

var Color = A.Color;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">B</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">B</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-v">B</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">B</span> <span class="pl-c1">=</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-k">var</span> <span class="pl-v">Color</span> <span class="pl-c1">=</span> <span class="pl-v">A</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">As pointed out by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/RyanCavanaugh/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/RyanCavanaugh">@RyanCavanaugh</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="39067312" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/306" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/306/hovercard" href="https://github.com/microsoft/TypeScript/issues/306">#306</a>, the compiler can elide the <code class="notranslate">var Color...</code> statement from inside <code class="notranslate">module B</code>. This is because inside <code class="notranslate">module B</code>, <code class="notranslate">Color</code> is a non-exported local variable and not subject to declaration merging (S10.5 of spec), so its scope is strictly limited to the interior of <code class="notranslate">module B</code> within <code class="notranslate">code.ts</code>. The compiler can thus reliably determine just from the source of <code class="notranslate">code.ts</code> that <code class="notranslate">Color</code> is not referenced anywhere, and elides it.</p>
<p dir="auto">The compiler <em>does</em> however emit a declaration for the outermost <code class="notranslate">Color</code>, even though it also has no references in the file. This is because <code class="notranslate">code.ts</code> is considered to be part of the <em>global module</em>, because as per S11.1 <em>"Implementation and declaration source files that contain no import or export declarations form the single global module"</em>. As such, another file contributing to the global module may refer to <code class="notranslate">Color</code>, so the compiler must emit the <code class="notranslate">var Color</code> at its point of declaration here in <code class="notranslate">code.ts</code>.</p>
<p dir="auto">So far so good.</p>
<p dir="auto">Now, we can make <code class="notranslate">code.ts</code> into an <em>external module</em> as per S11.1: <em>"Implementation and declaration source files that contain at least one external import declaration, export assignment, or top-level exported declaration are considered separate external modules"</em>. So if we add the line <code class="notranslate">export = A;</code> to the end of <code class="notranslate">code.ts</code>, like so:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare module A {
    export enum Color { Red=1, Green=2, Blue=3 }
}

module B {
    import Color = A.Color;
}

import Color = A.Color;
export = A;"><pre class="notranslate"><span class="pl-k">declare</span> module <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-k">enum</span> <span class="pl-smi">Color</span> <span class="pl-kos">{</span> <span class="pl-c1">Red</span><span class="pl-c1">=</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">Green</span><span class="pl-c1">=</span><span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-c1">Blue</span><span class="pl-c1">=</span><span class="pl-c1">3</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

module <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">then the compiler <em>does</em> elide the outermost <code class="notranslate">Color</code> declaration. The CommonJS output in <code class="notranslate">code.js</code> becomes:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var B;
(function (B) {
})(B || (B = {}));

module.exports = A;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">B</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">B</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-v">B</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">B</span> <span class="pl-c1">=</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">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-v">A</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">To summarize my understanding of the above results, the compiler can elide an <code class="notranslate">import</code> declaration provided that <strong>all three</strong> of the following points are true:</p>
<ol dir="auto">
<li>The <code class="notranslate">import</code> statement is scoped within an <em>external module</em>;</li>
<li>The variable created by the <code class="notranslate">import</code> is not exported, i.e. it is a non-exported local variable and not subject to declaration merging;</li>
<li>There are no references to the variable created by the <code class="notranslate">import</code> declaration within its entire scope, which is limited to the interior of the external module within the single source file where the declaration appears).</li>
</ol>
<p dir="auto">Coming finally to the point, if we add the line <code class="notranslate">var red = Color.Red;</code> to <code class="notranslate">code.ts</code> like so:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare module A {
    export enum Color { Red=1, Green=2, Blue=3 }
}

module B {
    import Color = A.Color;
}

import Color = A.Color;
var red = Color.Red;
export = A;"><pre class="notranslate"><span class="pl-k">declare</span> module <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-k">enum</span> <span class="pl-smi">Color</span> <span class="pl-kos">{</span> <span class="pl-c1">Red</span><span class="pl-c1">=</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">Green</span><span class="pl-c1">=</span><span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-c1">Blue</span><span class="pl-c1">=</span><span class="pl-c1">3</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

module <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">import</span> <span class="pl-smi">Color</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">.</span><span class="pl-smi">Color</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">red</span> <span class="pl-c1">=</span> <span class="pl-smi">Color</span><span class="pl-kos">.</span><span class="pl-c1">Red</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Then the compiler emits (CommonJS):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var B;
(function (B) {
})(B || (B = {}));

var Color = A.Color;
var red = 1 /* Red */;
module.exports = A;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">B</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">B</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-v">B</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">B</span> <span class="pl-c1">=</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-k">var</span> <span class="pl-v">Color</span> <span class="pl-c1">=</span> <span class="pl-v">A</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">red</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span> <span class="pl-c">/* Red */</span><span class="pl-kos">;</span>
<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-v">A</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Note that the outermost <code class="notranslate">Color</code> satisfies all three points above, in particular there are no references to it within its entire scope (thanks to the compiler emitting <code class="notranslate">1 /* Red */</code> instead of <code class="notranslate">Color.Red</code>. Yet, the compiler still emits the <code class="notranslate">var Color</code> declaration.</p>
<p dir="auto">Yes it's technically spec compliant, but it also creates seemingly needless problems in the following straightforward situation (as aluded to in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="39067312" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/306" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/306/hovercard" href="https://github.com/microsoft/TypeScript/issues/306">#306</a>):</p>
<ol dir="auto">
<li>An enum is used as an ambient type within an external module (i.e. the generated JS code contains no references to the enum's symbols, but only JS constants).</li>
<li>It is desirable to reference the enum through a short local alias, rather than having to fully-qualify it with its complete namespace at every reference site.</li>
</ol>
<p dir="auto">For example, the workaround for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="39067312" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/306" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/306/hovercard" href="https://github.com/microsoft/TypeScript/issues/306">#306</a> means writing something like:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Ensure Deeply.Nested.Module.Color is referenceable:
///&lt;reference path=&quot;./types.d.ts&quot; /&gt;

// CANNOT DO THIS because tsc will emit an unused local
//                whose assignment fails at runtime
//import Color = Deeply.Nested.Module.Color;

export = ... // This is an external module

...
switch (color) {
    case Deeply.Nested.Module.Color.Red: ...   // ...oh
    case Deeply.Nested.Module.Color.Green: ... // ...my
    case Deeply.Nested.Module.Color.Blue: ...  // ...wrist
}"><pre class="notranslate"><span class="pl-c">// Ensure Deeply.Nested.Module.Color is referenceable:</span>
<span class="pl-c">///&lt;reference path="./types.d.ts" /&gt;</span>

<span class="pl-c">// CANNOT DO THIS because tsc will emit an unused local</span>
<span class="pl-c">//                whose assignment fails at runtime</span>
<span class="pl-c">//import Color = Deeply.Nested.Module.Color;</span>

<span class="pl-k">export</span> <span class="pl-c1">=</span> ... <span class="pl-c">// This is an external module</span>

...
<span class="pl-k">switch</span> <span class="pl-kos">(</span><span class="pl-s1">color</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-smi">Deeply</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Module</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">.</span><span class="pl-c1">Red</span>: ...   <span class="pl-c">// ...oh</span>
    <span class="pl-k">case</span> <span class="pl-smi">Deeply</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Module</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">.</span><span class="pl-c1">Green</span>: ... <span class="pl-c">// ...my</span>
    <span class="pl-k">case</span> <span class="pl-smi">Deeply</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Module</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">.</span><span class="pl-c1">Blue</span>: ...  <span class="pl-c">// ...wrist</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This scenario (wanting to locally alias an enum) is hardly esoteric, but seems not to be possible unless the compiler elides the provably-never-referenced alias declaration.</p>