title: TypeScript error: Property 'X' does not exist on type 'Window'
body: <p>I have added TS to my React/Redux app.</p>
  
  <p>I use <code>window</code> object in my app like this:</p>
  
  <pre><code>componentDidMount() {
    let FB = window.FB;
  }
  </code></pre>
  
  <p>TS throws an error:</p>
  
  <blockquote>
    <p>TypeScript error: Property 'FB' does not exist on type 'Window'. TS2339</p>
  </blockquote>
  
  <p>I want to fix the error.</p>
  
  <h3>1 (doesn't work)</h3>
  
  <pre><code>// Why doesn't this work? I have defined a type locally
  
  type Window = {
    FB: any
  }
  
  componentDidMount() {
    let FB = window.FB;
  }
  
  // TypeScript error: Property 'FB' does not exist on type 'Window'. TS2339
  </code></pre>
  
  <h3>2 (fixes the error)</h3>
  
  <p>I found the answer here <a href="https://stackoverflow.com/a/56402425/1114926">https://stackoverflow.com/a/56402425/1114926</a></p>
  
  <pre><code>declare const window: any;
  
  componentDidMount() {
    let FB = window.FB;
  }
  // No errors, works well
  </code></pre>
  
  <p>Why doesn't the first version work, but the second does, even though I do not specify FB property at all?</p>