Skip to content

Google Maps Places Typescript: Cannot find Namespace 'google' #32

@seanaye

Description

@seanaye

Environment details

Package manager: yarn 1.22.4
@googlemaps/js-api-loader: "^1.2.0"
ts config:

{
  "extends": "@quasar/app/tsconfig-preset",
  "compilerOptions": {
    "target": "ES5",
    "lib": [
      "ES2019", "DOM"
    ],
    "baseUrl": ".",
    "experimentalDecorators": true,
    "importHelpers": true,
    "skipLibCheck": true,
    "typeRoots": [
      "node_modules/@types",
      "src/types"
    ],
    ...
}

Steps to reproduce

  1. Migrating from google-maps package

Code example

import { Loader, LoaderOptions, } from '@googlemaps/js-api-loader'
import { ref } from '@vue/composition-api'

const opts: LoaderOptions = {
  libraries: ['places'],
  apiKey: 'MY_API_KEYI'
}

const loader = new Loader(opts)

const loaded = ref(false)

const autocompleteObject = ref<google.maps.places.AutocompleteService|null>(null)
const placeDetailsObject = ref<google.maps.places.PlacesService|null>(null)

results in

Cannot find namespace 'google'.ts(2503)

EDIT:

Should mention that in google-maps package my import statement had

import { Loader, LoaderOptions, google } from 'google-maps'

this is removed because

node_modules/@googlemaps/js-api-loader/dist"' has no exported member 'google'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions