title: TypeScript React Google Maps: 'google' does not exist
body: <p>I have loaded the google maps Javascript API in the <code>public/index.html</code> and in dev tools console I can log <code>window.google.maps</code> just fine.</p>
  
  <p><a href="https://i.stack.imgur.com/XqeG5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XqeG5.png" alt="enter image description here"></a></p>
  
  <p>But TypeScript doesn't know its there and I get this error <code>Property 'google' does not exist on type 'Window &amp; typeof globalThis'.ts(2339)</code> How do I tell typescript it does exist?</p>
  
  <pre><code>import React, { useRef } from "react";
  
  function Map() {
      const mapRef = useRef&lt;HTMLDivElement&gt;(null);
      const google = window.google;
  //                          ^ Error: Property 'google' does not exist on type 'Window &amp; typeof globalThis'
      const myLatlng = new google.maps.LatLng(-34.397, 150.644);
      const mapOptions = {
      zoom: 8,
      center: myLatlng,
      };
      const map = new google.maps.Map(mapRef.current, mapOptions);
    return (&lt;div ref={mapRef}&gt;&lt;/div&gt;);
  }
  
  export { Map };
  </code></pre>