<p dir="auto">I found a strange behaviour when importing a default-exported module from file1 and using it for variable/parameter/return value/whatever... type declarations in file2. Please note that the imported namespace is still visible and works correctly when I use it for variable definitions (e.g. invoking class constructor with new). See the code below:</p>
<p dir="auto">file1.ts</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export module a {
    export module b {
        export class MyClass {
            x: number = 10;
        }
    }
}

export default a.b;"><pre class="notranslate"><span class="pl-k">export</span> module <span class="pl-s1">a</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> module <span class="pl-s1">b</span> <span class="pl-kos">{</span>
        <span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">MyClass</span> <span class="pl-kos">{</span>
            <span class="pl-c1">x</span>: <span class="pl-smi">number</span> <span class="pl-c1">=</span> <span class="pl-c1">10</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">export</span> <span class="pl-k">default</span> <span class="pl-s1">a</span><span class="pl-kos">.</span><span class="pl-c1">b</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">file2.ts</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import y from './file1';

function fn(): y.MyClass {      //warning here: Cannot find namespace 'y'.
    return new y.MyClass();     //it works here, no compiler warning
}

var a = fn();                   //works fine
var b: y.MyClass = fn();        //warning here: Cannot find namespace 'y'.

function fn2(i: y.MyClass) {    //warning here: Cannot find namespace 'y'.
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">y</span> <span class="pl-k">from</span> <span class="pl-s">'./file1'</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">fn</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-s1">y</span><span class="pl-kos">.</span><span class="pl-smi">MyClass</span> <span class="pl-kos">{</span>      <span class="pl-c">//warning here: Cannot find namespace 'y'.</span>
    <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-s1">y</span><span class="pl-kos">.</span><span class="pl-c1">MyClass</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>     <span class="pl-c">//it works here, no compiler warning</span>
<span class="pl-kos">}</span>

<span class="pl-k">var</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-en">fn</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>                   <span class="pl-c">//works fine</span>
<span class="pl-k">var</span> <span class="pl-s1">b</span>: <span class="pl-s1">y</span><span class="pl-kos">.</span><span class="pl-smi">MyClass</span> <span class="pl-c1">=</span> <span class="pl-en">fn</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>        <span class="pl-c">//warning here: Cannot find namespace 'y'.</span>

<span class="pl-k">function</span> <span class="pl-en">fn2</span><span class="pl-kos">(</span><span class="pl-s1">i</span>: <span class="pl-s1">y</span><span class="pl-kos">.</span><span class="pl-smi">MyClass</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>    <span class="pl-c">//warning here: Cannot find namespace 'y'.</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Instead, for class expression (<code class="notranslate">export default class {...</code> in file1.ts) it works fine, both for type declarations and variable definitions.</p>
<p dir="auto">Current description of export assignments in the spec states:</p>
<blockquote>
<p dir="auto">Export assignments exist for backward compatibility with earlier versions of TypeScript. An export assignment designates a module member as the entity to be exported in place of the module itself.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  ExportAssignment:
   export = IdentifierReference ;"><pre class="notranslate">  ExportAssignment:
   <span class="pl-k">export</span> <span class="pl-c1">=</span> <span class="pl-smi">IdentifierReference</span> <span class="pl-kos">;</span></pre></div>
<p dir="auto">A module containing an export assignment can be imported using an import require declaration (11.3.3), and the local alias introduced by the import require declaration then takes on all meanings of the <strong>identifier</strong> named in the export assignment.</p>
</blockquote>
<p dir="auto">However current implementation also <a href="https://github.com/Microsoft/TypeScript/blob/master/src/compiler/binder.ts#L948">permits</a> dotted names - in this case only value meaning is exported. This change seems to be quite recent, example below compiles with no errors in current master and issues a syntax error <code class="notranslate">';' expected."</code>in v1.4.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare module foo.bar {
    export type X = number;
    export var X: { A: number };
}

declare module &quot;test&quot; {
    export = foo.bar;
}"><pre class="notranslate"><span class="pl-k">declare</span> module <span class="pl-s1">foo</span><span class="pl-kos">.</span><span class="pl-s1">bar</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">X</span> <span class="pl-c1">=</span> <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-k">export</span> <span class="pl-k">var</span> <span class="pl-smi">X</span>: <span class="pl-kos">{</span> <span class="pl-c1">A</span>: <span class="pl-smi">number</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">declare</span> module <span class="pl-s">"test"</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-c1">=</span> <span class="pl-s1">foo</span><span class="pl-kos">.</span><span class="pl-c1">bar</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This issue can have several interpretations:</p>
<ul dir="auto">
<li>this is only spec bug - current behavior for dotted names should be documented</li>
<li>this is both spec and implementation issue - we export all meanings also for dotted names and spec should be adjusted to reflect this</li>
<li>this is implementation bug - we should prohibit usage of dotted names in export assignments.</li>
</ul>