Angular 6 - @types/googlemaps/index.d.ts' is not a module

For Angular6~

  1. npm install @types/googlemaps --save-dev or yarn add @types/googlemaps
  2. Add "googlemaps" to tsconfig.app.json types array

adding 'googlemaps' to tsconfig.app.json example (Line 6)

  1. Add "googlemaps" to tsconfig.spec.json types array

adding 'googlemaps' to tsconfig.app.json example (Line 8)

  1. Add /// <reference types="@types/googlemaps" /> on the first line of your component.ts file. This line will import @types/googlemaps. (Line1 of example below)
  2. Declare google variable as declare let google: any; (Line6 of example below)

enter image description here

Ref:

  • https://stackoverflow.com/a/52200117/10009565

You probably don't need this line in your component.ts file (It's only for Angular <6):

import { } from '@types/googlemaps';

Here's an (basic/minimal) example for Angular 6:

/// <reference types="@types/googlemaps" />
map: google.maps.Map;
this.map = new google.maps.Map(....);

Basically, if you want to use it in Angular <6, you have to add it via the import method. In Angular 6+ you have to add it via the reference method. You shouldn't add both at the same time.

Hope I could help.