title: How do you explicitly set a new property on `window` in TypeScript?
body: <p>I setup global namespaces for my objects by explicitly setting a property on <code>window</code>.</p>
  
  <pre><code>window.MyNamespace = window.MyNamespace || {};
  </code></pre>
  
  <p>TypeScript underlines <code>MyNamespace</code> and complains that:</p>
  
  <blockquote>
    <p>The property 'MyNamespace' does not exist on value of type 'window'
    any"</p>
  </blockquote>
  
  <p>I can make the code work by declaring <code>MyNamespace</code> as an ambient variable and dropping the <code>window</code> explicitness but I don't want to do that.</p>
  
  <pre><code>declare var MyNamespace: any;
  
  MyNamespace = MyNamespace || {};
  </code></pre>
  
  <p>How can I keep <code>window</code> in there and make TypeScript happy?</p>
  
  <p>As a side note I find it especially funny that TypeScript complains since it tells me that <code>window</code> is of type <code>any</code> which by definitely can contain anything.</p>