<p dir="auto">I'm unable to <code class="notranslate">export default</code> modules/namespaces like this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default namespace Utils { // throws  error TS1005: ';' expected
..."><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">namespace</span> <span class="pl-smi">Utils</span> <span class="pl-kos">{</span> <span class="pl-c">// throws  error TS1005: ';' expected</span>
...</pre></div>
<p dir="auto">Not sure if its related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="94019726" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/3792" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/3792/hovercard" href="https://github.com/microsoft/TypeScript/issues/3792">#3792</a>, but that isn't actually my issue...<br>
Since I can't <code class="notranslate">export default</code> the namespace directly, I would like to convention that default exports should be placed in a separate statement and always put in the first lines of the file:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export default Utils

import * as Foo from &quot;foo&quot;
// ...
import {Bar, Baz} from &quot;bar&quot;

let fooIt = Foo.Factory.SpecialFoo.Create
// ...

namespace Utils {
  // ...
}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-smi">Utils</span>

<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">Foo</span> <span class="pl-k">from</span> <span class="pl-s">"foo"</span>
<span class="pl-c">// ...</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-smi">Bar</span><span class="pl-kos">,</span> <span class="pl-smi">Baz</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"bar"</span>

<span class="pl-k">let</span> <span class="pl-s1">fooIt</span> <span class="pl-c1">=</span> <span class="pl-smi">Foo</span><span class="pl-kos">.</span><span class="pl-c1">Factory</span><span class="pl-kos">.</span><span class="pl-c1">SpecialFoo</span><span class="pl-kos">.</span><span class="pl-c1">Create</span>
<span class="pl-c">// ...</span>

<span class="pl-k">namespace</span> <span class="pl-smi">Utils</span> <span class="pl-kos">{</span>
  <span class="pl-c">// ...</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">IMO it would improve readability and make it easier to understand how to consume that file/module.</p>
<p dir="auto">Despite the fact that the compiler seems to understand that I'm exporting the <code class="notranslate">Utils</code> namespace, the transpiled code does not associate the export statement and my internal module, <a href="http://www.typescriptlang.org/Playground#src=%2F%2F%20'var%20Utils'%20could%20be%20transpiled%20over%20here%0Aexport%20default%20Utils%20%0A%0Anamespace%20Utils%20%7B%0A%20%20export%20function%20test%28%29%20%7B%0A%09%20%20console.log%28'TEST'%29%0A%20%20%7D%0A%7D" rel="nofollow">causing the default export to be undefined at run time</a>.</p>
<p dir="auto">Would be nice to get <code class="notranslate">export default</code> transpiled to the of the file or declare the module container earlier, so I can export it wherever I want.</p>
<p dir="auto">If <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="94019726" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/3792" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/3792/hovercard" href="https://github.com/microsoft/TypeScript/issues/3792">#3792</a> gets fixed I can just convention that the default module should always come first, and keep my default export always on sight. So this is issue is more like a suggestion I suppose...</p>
<p dir="auto"><sub>Typescript Version 1.9.0-dev.20160220</sub></p>
<p dir="auto">Hi,</p>
<p dir="auto">If I have the following typescript code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var obj = {
    someKey: 6
};

// For some reason I want to change the object
obj = {
    someKey: 7
};

export {obj};"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">6</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">// For some reason I want to change the object</span>
<span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">7</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-kos">{</span><span class="pl-s1">obj</span><span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">it compiles to:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var obj = {
    someKey: 6
};
exports.obj = obj;
obj = {
    someKey: 7
};"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">6</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">obj</span> <span class="pl-c1">=</span> <span class="pl-s1">obj</span><span class="pl-kos">;</span>
<span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">7</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">So if I importing the object I get:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {obj} from './some-file';
console.log(obj.someKey === 6); // true"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">obj</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./some-file'</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">obj</span><span class="pl-kos">.</span><span class="pl-c1">someKey</span> <span class="pl-c1">===</span> <span class="pl-c1">6</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// true</span></pre></div>
<p dir="auto">But I was expecting <code class="notranslate">7</code>. I.e. I was expecting the following JS code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var obj = {
    someKey: 6
};
obj = {
    someKey: 7
};
exports.obj = obj;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">6</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-s1">obj</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">someKey</span>: <span class="pl-c1">7</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">obj</span> <span class="pl-c1">=</span> <span class="pl-s1">obj</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Is this a bug or expected behavior?</p>
<p dir="auto">I am using version <code class="notranslate">1.6.0-dev.20150731</code> but it has the same behavior in <code class="notranslate">1.5.3</code>.</p>