TypeScript Error: Cannot find namespace 'google'

In IONIC 4 I fixed it by installing @types/google-maps not @types/googlemaps

just run this

npm install @types/google-maps --save

and import google in your component using

import { google } from "google-maps";

I was facing same problem and what I did was, I just removed these

import { } from 'googlemaps';
declare var google: any;

from my component.ts and add "types": [ "googlemaps" ] in my tsconfig.app.json . . Now my tsconfig.app.json looks like this.

{
    "extends": "../tsconfig.json",
    "compilerOptions": {
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "types": [
            "googlemaps"
          ]
    },
    "exclude": [
        "test.ts",
        "**/*.spec.ts"
    ]
}

And its working perfectly.


A bit of a late response but I had a similar issue using Angular CLI RC.0.

It turned out that I hadn't install and imported the typings, which can be done as follows:

npm install --save-dev @types/googlemaps

import {} from '@types/googlemaps';