title: Exported variable X has or is using name Y from external module Z but cannot be named
body: <p>I get the following error in this case using TS 3.9 with <code>{ compilerOptions: {declaration: true }}</code> in my tsconfig.json:</p>
  <pre><code>// a.ts
  export const key = 1234
  export const obj = {
      [key]: 1
  };
  export default obj;
  
  // b.ts
  import A from &quot;./a&quot;;
  import { key} from &quot;./a&quot;
  
  // Exported variable 'theExport' has or is using name 'key' from external module &quot;c:/tsexample/src/a&quot; but cannot be named.ts(4023)
  const theExport  = {
    A: A,
    B: 2,
    C: 3,
  };
  export default theExport
  </code></pre>
  <pre><code>// Exported variable 'theExport' has or is using name 'key' from external module &quot;c:/tsexample/src/a&quot; but cannot be named.ts(4023)
  </code></pre>
  <p>In <a href="https://github.com/microsoft/TypeScript/issues/9944#issuecomment-244448079" rel="noreferrer">a comment on a related issue</a> the PM of TS at the time suggested two workarounds:</p>
  <ol>
  <li>explicitly import the type</li>
  <li>explicitly declare the type of the export (where the error occurs)</li>
  </ol>
  <p>(1) does not work in this case. I tried exporting everything from 'a' and importing everything in 'b' and there was no difference to the error message.</p>
  <p>The only thing that worked was this very verbose and hard to maintain explicit type annotation:</p>
  <pre><code>// updated b.ts
  import A from &quot;./a&quot;;
  
  const theExport: {
      // https://github.com/microsoft/TypeScript/issues/9944
    [index: string]: typeof A | number;
  } = {
    A: A,
    B: 2,
    C: 3,
  };
  export default theExport;
  </code></pre>
  <p>My question is:</p>
  <ul>
  <li>what is a workaround I can use that doesn't involve repeating the shape of the object?</li>
  <li>why does importing the type not fix the problem?</li>
  </ul>
  <p>This question is similar but distinct from:</p>
  <ul>
  <li><a href="https://stackoverflow.com/a/44066867/2482570">https://stackoverflow.com/a/44066867/2482570</a>: not relevant because it says the problem was fixed in TS 2.9</li>
  <li><a href="https://stackoverflow.com/a/49841010/2482570">https://stackoverflow.com/a/49841010/2482570</a>: none of the answers provide a workaround that is applicable to this case</li>
  <li><a href="https://stackoverflow.com/questions/48520350/typescript-error-return-type-of-exported-function-has-or-is-using-name-n-fro">Typescript error: &quot;Return type of exported function has or is using name &lt;n&gt; from external module &lt;M&gt; but cannot be named&quot;</a> and <a href="https://stackoverflow.com/questions/39807253/typing-error-default-export-of-the-module-has-or-is-using-private-name-switc">Typing error &quot;Default export of the module has or is using private name&quot; - switch from typescript v1.8 to 2</a>: none of the solutions provided work in this case</li>
  </ul>