Why does the typescript transpiler not hoist variables?
<p>I understand that ES6 and TypeScript both support block level scoping, but when targeting ES3 and ES5 the output should be function level scoping. I think there has to be a logic behind why TypeScript isn't hoisting variables.. and I'm not running into a problem, I'm more just curious why it doesn't hoist variables. </p>

<p>For example, given the following TypeScript:</p>

<pre><code>function seed(length: number, multiplier: number): number[] {
  let result: number[] = [];

  for(let i: number = 0; i &lt; length; i++) {
    let n: number = i * multiplier;

    result.push(n);
  }

  return result;
}
</code></pre>

<p>The transpiler outputs:</p>

<pre><code>function seed(length, multiplier) {
  var result = [];
  for (var i = 0; i &lt; length; i++) {
    var n = i * multiplier;
    result.push(n);
  }
  return result;
}
</code></pre>

<p>The result I would have expected would be one with the variable declarations hoisted to the top of the function. Looking something like this:</p>

<pre><code>function seed(length, multiplier) {
  var
    i, n,
    result = [];

  for (i = 0; i &lt; length; i++) {
    n = i * multiplier;
    result.push(n);
  }
  return result;
}
</code></pre>

<p>Any insight is greatly appreciated. Thanks!</p>