<p dir="auto">It appears that export assignments (<code class="notranslate">export = x</code>) when compiling <code class="notranslate">amd</code> modules for either <code class="notranslate">es5</code> or <code class="notranslate">es6</code> output to a single file, is broken?</p>
<p dir="auto">For example, <a href="https://bitbucket.org/mindplaydk/scribe-ts/src/36ff20d173fd5bd28a61bf7efe461469136248f7/src/scribe/plugins/core/set-root-p-element.ts?at=typescript&amp;fileviewer=file-view-default" rel="nofollow">this</a> file:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { Scribe } from &quot;../../../scribe&quot;

/**
 * Sets the default content of the scribe so that each carriage return creates
 * a P.
 */

export = function(scribe: Scribe) {
    // The content might have already been set, in which case we don't want
    // to apply.
    if (scribe.getHTML().trim() === '') {
        /**
         * We have to begin with the following HTML, because otherwise some
         * browsers(?) will position the caret outside of the P when the scribe is
         * focused.
         */
        scribe.setContent('&lt;p&gt;&lt;br&gt;&lt;/p&gt;')
    }
}"><pre class="notranslate"><code class="notranslate">import { Scribe } from "../../../scribe"

/**
 * Sets the default content of the scribe so that each carriage return creates
 * a P.
 */

export = function(scribe: Scribe) {
    // The content might have already been set, in which case we don't want
    // to apply.
    if (scribe.getHTML().trim() === '') {
        /**
         * We have to begin with the following HTML, because otherwise some
         * browsers(?) will position the caret outside of the P when the scribe is
         * focused.
         */
        scribe.setContent('&lt;p&gt;&lt;br&gt;&lt;/p&gt;')
    }
}
</code></pre></div>
<p dir="auto">Produces the following <code class="notranslate">.d.ts</code> output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="declare module &quot;scribe/plugins/core/set-root-p-element&quot; {
    import { Scribe } from &quot;scribe&quot;;
    declare var _default: (scribe: Scribe) =&gt; void;
    export = _default;
}"><pre class="notranslate"><code class="notranslate">declare module "scribe/plugins/core/set-root-p-element" {
    import { Scribe } from "scribe";
    declare var _default: (scribe: Scribe) =&gt; void;
    export = _default;
}
</code></pre></div>
<p dir="auto">Which, when I attempt to include that, complains that <code class="notranslate">declare</code> is not allowed inside a <code class="notranslate">declare module</code> block. A nested <code class="notranslate">declare</code> statement is emitted for every export assignment.</p>
<p dir="auto">Interestingly, if I change the module type to <code class="notranslate">system</code>, the compiler complains (at compile-time) about every export assignment - it's as though this was supposed to be supported for <code class="notranslate">amd</code>, but isn't really? I would expect it should be supported, as it's a very common pattern in amd modules in vanilla JS.</p>
<p dir="auto">I'm using Typescript 1.8.10.</p>
<p dir="auto">My <a href="https://bitbucket.org/mindplaydk/scribe-ts/src/36ff20d173fd5bd28a61bf7efe461469136248f7/src/?at=typescript&amp;fileviewer=file-view-default" rel="nofollow">tsconfig</a> is set for <code class="notranslate">es6</code> and <code class="notranslate">amd</code> output to a single file.</p>
<p dir="auto">The resulting <code class="notranslate">.d.ts</code> output is <a href="https://bitbucket.org/mindplaydk/scribe-ts/src/36ff20d173fd5bd28a61bf7efe461469136248f7/dist/scribe.d.ts?at=typescript&amp;fileviewer=file-view-default" rel="nofollow">here</a>.</p>
<p dir="auto">The full project is available <a href="https://bitbucket.org/mindplaydk/scribe-ts/src" rel="nofollow">here</a>.</p>
<p dir="auto">Why doesn't this work?</p>
<p dir="auto">Is there a viable way to build amd modules with <code class="notranslate">.d.ts</code> headers with TS and package them as npm modules with typings?</p>
<p dir="auto">I have been told I should use commonjs as my compile target, and then use grunt and browserify to single-file the module - but I don't understand why I should need a whole stack of tools on top of the language just to get it to work? (I also don't understand how this supposedly leads to a working <code class="notranslate">.d.ts</code> file...)</p>
<p dir="auto">I really do not want a large, complicated build chain - I just want to compile my module to a file, emit the matching header file, run uglifyjs and be done.</p>
<p dir="auto">Please advise? How should I proceed?</p>
<p dir="auto"><code class="notranslate">window.fetch(...)</code></p>
<blockquote>
<p dir="auto">error TS2304: Cannot find name 'fetch'.</p>
</blockquote>