<p dir="auto">Hi there, I come from a C# background and it has something great call Object Initializer. Which allows you to initialize an object inline, without specifying the object everytime.</p>
<p dir="auto">C# docs:<br>
<a href="https://msdn.microsoft.com/en-us/library/bb397680.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/bb397680.aspx</a></p>
<p dir="auto">I would be cool if the compiler could do something like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="new MyClass { Field1 = &quot;ASD&quot;, Field2 = &quot;QWE&quot; };"><pre class="notranslate"><span class="pl-k">new</span> <span class="pl-v">MyClass</span><span class="pl-kos"></span> <span class="pl-kos">{</span> <span class="pl-v">Field1</span> <span class="pl-c1">=</span> <span class="pl-s">"ASD"</span><span class="pl-kos">,</span> <span class="pl-v">Field2</span> <span class="pl-c1">=</span> <span class="pl-s">"QWE"</span> <span class="pl-kos">}</span><span class="pl-kos">;</span></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="{
  let foo = 'bar';
}

console.log(foo)
"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-k">let</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s">'bar'</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">foo</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">I would expect <code class="notranslate">let foo = 'bar';</code> to be emitted as <code class="notranslate">var foo_1 = 'bar';</code></p>
<p dir="auto">When running the emitted code I would expect to get a Reference Error for <code class="notranslate">foo</code></p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    var foo = 'bar';
}
console.log(foo);
"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s">'bar'</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">foo</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">There is no Reference Error in emitted code and <code class="notranslate">bar</code> is printed to the console.</p>