Я загрузил API Google Maps Javascript в public/index.html
и в консоли инструментов разработчика я могу войти window.google.maps
очень хорошо.
Но TypeScript не знает его там, и я получаю эту ошибку Property 'google' does not exist on type 'Window & typeof globalThis'.ts(2339)
Как мне узнать машинопись, она существует?
import React, { useRef } from "react";
function Map() {
const mapRef = useRef<HTMLDivElement>(null);
const google = window.google;
// ^ Error: Property 'google' does not exist on type 'Window & 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 (<div ref={mapRef}></div>);
}
export { Map };