TypeScript Error: Cannot find namespace 'google'

后端 未结 7 632
青春惊慌失措
青春惊慌失措 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:38

    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.

    0 讨论(0)
提交回复
热议问题