title: Exporting enum in `.d.ts` leads to „Can't resolve” error
body: <p>yesterday I was adding an <code>enum</code> to our <code>app.d.ts</code> file, which holds most of the global app-specific types.</p>
  <p>The file looks roughly like this:</p>
  <pre class="lang-js prettyprint-override"><code>// app.d.ts
  export module App
  {
      // … more definitions
  
      enum MyEnum
      {
          A,
          B,
          C,
          D
      }
  }
  </code></pre>
  <p>Which in itself is compiling fine. Now, if you try to use said enum in a different file like this:</p>
  <pre class="lang-js prettyprint-override"><code>// a.ts
  import {App} from &quot;./app&quot;;
  
  let something = App.MyEnum.A;
  </code></pre>
  <p>TypeScript is complaining that it suddenly can't resolve the file <code>app.d.ts</code>.</p>
  <p><a href="https://i.stack.imgur.com/RqXVo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RqXVo.png" alt="TypeScript compile error" /></a></p>
  <p>After a lot of debugging and reading through the docs, I found the <a href="https://www.typescriptlang.org/docs/handbook/enums.html#enums-at-runtime" rel="nofollow noreferrer">following disclaimer</a>:</p>
  <blockquote>
  <p>Enums are real objects that exist at runtime</p>
  </blockquote>
  <p>So when moving <code>MyEnum</code> from <code>app.d.ts</code> to its own <code>MyEnum.ts</code> file and explicitly exporting it, it suddenly works:</p>
  <pre class="lang-js prettyprint-override"><code>// MyEnum.ts
  export enum MyEnum
  {
      A,
      B,
      C,
      D
  }
  </code></pre>
  <ul>
  <li></li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>// a.ts
  import {MyEnum} from &quot;./MyEnum&quot;;
  
  let something = MyEnum.A;
  </code></pre>
  <p>So now my real question is: Is this due to the fact that TypeScript doesn't inline enum values into constants (unless you're using <code>const enum</code>) but keeps them around as real objects, and since the <code>.d.ts</code> files are basically thrown away when compiling TypeScript into JavaScript, it fails with this very weird and sort of unrelated error message?</p>