title: How to override a TypeScript UMD global type definition?
body: <p>I have installed <code>three@^0.103.0</code>, which has its own type definitions.</p>
  
  <p>In <code>src/global.d.ts</code> of my project I have:</p>
  
  <pre><code>import * as _THREE from 'three'
  
  declare global {
      const THREE: typeof _THREE
  }
  </code></pre>
  
  <p>Then in <code>src/global.ts</code> I have</p>
  
  <pre><code>import * as THREE from 'three'
  (window as any).THREE = { ...THREE }
  </code></pre>
  
  <p>Then in <code>src/my-code.js</code> I am trying to use the <code>THREE</code> as a global variable, f.e.</p>
  
  <pre><code>console.log(new THREE.Vector3(1,2,3)) // ERROR, 'THREE' refers to a UMD global, but the current file is a module. Consider adding an import instead.
  </code></pre>
  
  <p>It tells me that <code>'THREE' refers to a UMD global, but the current file is a module. Consider adding an import instead.</code>.</p>
  
  <p>When I jump to the definition of <code>THREE</code>, it takes me to <code>node_modules/three/src/Three.d.ts</code>, which is not my <code>src/global.d.ts</code> file.</p>
  
  <p>So, it seems like TypeScript is ignoring my <code>global.d.ts</code> definitions?</p>
  
  <p>My <code>tsconfig.json</code> contains</p>
  
  <pre><code>  "allowJs" true,
    "checkJs" true,
    "include": ["src/**/*"]
  </code></pre>
  
  <p>and I have <code>global.d.ts</code> is inside of <code>src</code>.</p>
  
  <p>If I add</p>
  
  <pre><code>/// &lt;reference path="./global.d.ts" /&gt;
  </code></pre>
  
  <p>to the top of <code>src/my-code.js</code> file (JavaScript), then it works, and I can jump to the definition of <code>THREE</code> which takes me to my <code>global.d.ts</code> file.</p>
  
  <p>Why does it not work without the <code>reference</code> comment?</p>