'let and 'var' are the same in Typescript?
<p>I was taking a look at AngularJS 2 and Typescript and I decided to make something with this just to learn the basics of Typescript. With many research I found good topics about modules, Typescript, and one of them was talking about the 'let' and 'var' command to declare variables; according to <a href="https://stackoverflow.com/questions/762011/let-keyword-vs-var-keyword">this</a> question, the Typescript code below should display only one alert and throw an error in the console:</p>

<p><strong><em>test.ts:</em></strong></p>

<pre><code>for(let i = 0; i &lt; 1; i++) {
    alert(i);
}
alert(i);
</code></pre>

<p><strong><em>Compiled test.js:</em></strong></p>

<pre><code>for(var i = 0; i &lt; 1; i++) {
    alert(i);
}
alert(i);
//# sourceMappingURL=test.js.map
</code></pre>

<p>But it isn't. The compiler "ignores" the "let" command and turns it into the "var" command. Why does this happen? Does Typescript only works properly with classes?</p>

<p>I'm using AngularJS configuration for 'npm start', so it compiles my 'test.ts' file automatically:</p>

<pre><code>  "scripts": {
    "start": "tsc &amp;&amp; concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
</code></pre>