TypeScript Error: Cannot find namespace 'google'

后端 未结 7 636
青春惊慌失措
青春惊慌失措 2021-01-12 06:33

I have project angular-cli

~root~/src/typings.json

{
  \"globalDevDependencies\": {
    \"angular-protractor\": \"registry:dt/angula         


        
7条回答
  •  花落未央
    2021-01-12 07:37

    For Angular 9.****

    I tried installing @types/googlemaps, It did not work for me.

    I downgrade it to "@types/googlemaps": "3.39.12" then worked perfectly fine.

    this is my code

    In tsconfig.app.json (add googlemaps to types array)

    "types": [
          "googlemaps"
        ]
    

    In app module.ts

    import { AgmCoreModule } from '@agm/core';
    .
    .
    .
    .
     imports: [
        BrowserModule,
        AppRoutingModule,
        AgmCoreModule.forRoot({
          apiKey: '...KEY...',
          libraries: ['places']
        })
      ],
    

    To downgrade @types/googlemaps, go to pakage.json file in the project root folder and change @types/googlemaps version to "3.39.12". it's better if you delete files form

    node_module -> @types -> googlemaps
    

    Then in the terminal enter

    npm install
    

提交回复
热议问题