Typescript Error Cannot find name 'google' in ionic2 when using googlemaps javascript API Typescript Error Cannot find name 'google' in ionic2 when using googlemaps javascript API typescript typescript

Typescript Error Cannot find name 'google' in ionic2 when using googlemaps javascript API


I solved it by installing:

$npm install @types/googlemaps --save-dev


To expand on the answer from @suraj, you should have:

declare var google; 

outside of the class you are trying to use it in.

Just like in the Josh Morony video, I put it beneath the imports but before the class declaration and annotations (@Injectable() and so forth). I suppose it would still work if you put it above the imports or beneath the end of the class (and still outside of the class), if you were so inclined for whatever reason.


npm install --save-dev @types/googlemapsimport {} from '@types/googlemaps';

from this answer

Or

in your component.ts file of your page declare it like this

declare var google; before export class component {}

An easy way Angular 6+ available in typescript is:

You only have to add this line at the beginning (meaningline 1, with nothing before) of your Typescript file :

/// <reference types="@types/googlemaps" />

And then

import {RemainingItems} from 'whicheverfolderyouwant';

Updated from