title: How can I add a typed property to the window object in a module?
body: <p>I currently have a file <code>main.ts</code> with code as follows:</p>
  
  <pre><code>import Game from './game';
  
  declare global {
      interface Window {
          game: Game;
          throttleScreenResizeRender: number;
          resizeTimeout: number;
      }
  }
  
   ...
  
  window.throttleScreenResizeRender = 0;
  </code></pre>
  
  <p>This works fine, but I'm trying to get the Window typings in a separate file to avoid code duplication. My current attempt looks like this:</p>
  
  <pre><code>// window.d.ts
  
  import Game from './game';
  
  declare global {
      interface Window {
          game: Game;
          throttleScreenResizeRender: number;
          resizeTimeout: number;
      }
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>// main.ts
  
  import Game from './game';
  import 'interfaces/window';
  
  window.throttleScreenResizeRender = 0;
  </code></pre>
  
  <p>This gives me a <code>Error TS2339: Property 'throttleScreenResizeRender' does not exist on type 'Window'.</code> on compilation.</p>
  
  <p>I'm using Typescript version 2.0.3</p>
  
  <p>How can I achieve this?</p>
  
  <p>EDIT </p>
  
  <p>I'm using Browserify with tsify as indicated by <a href="https://www.typescriptlang.org/docs/handbook/gulp.html" rel="nofollow noreferrer" title="the handbook">the handbook</a>. This is my gulp file:</p>
  
  <pre><code>const gulp = require("gulp");
  const browserify = require("browserify");
  const source = require('vinyl-source-stream');
  const tsify = require("tsify");
  
  ...
  
  gulp.task('tsify', function () {
      return browserify({
          basedir: '.',
          debug: true,
          entries: ['src/main.ts'],
          cache: {},
          packageCache: {}
      })
      .plugin(tsify)
      .bundle()
      .pipe(source('bundle.js'))
      .pipe(gulp.dest(destinationPath));
  });
  </code></pre>
  
  <p>Relevant <code>packages.json</code>:</p>
  
  <pre><code>  "dependencies": {
      "gulp": "^3.9.1",
      "gulp-typescript": "^3.0.2",
      "typescript": "^2.0.3"
    },
    "devDependencies": {
      "browserify": "^13.1.0",
      "gulp": "^3.9.1",
      "gulp-typescript": "^3.0.2",
      "tsify": "^2.0.2",
      "typescript": "^2.0.3",
      "vinyl-source-stream": "^1.1.0"
    },
  </code></pre>