googlemaps / js-types

Automatically generated types for the Google Maps Platform JavaScript API
Apache License 2.0
8 stars 7 forks source link

Incorrect type in `google.maps.GeocoderResult` #78

Open nbouvrette opened 1 year ago

nbouvrette commented 1 year ago

I'm not sure if this is the right place to fill this issue since I could not open issues on https://github.com/googlemaps/DefinitelyTyped

I was looking for a simple type for the Geocode API. Right now the API's type would look something like this:

type GoogleGeocodeApiResponse = {
  results: {
    address_components: {
      long_name: string
      short_name: string
      types: string[]
    }[]
    formatted_address: string
    geometry: {
      bounds: Record<string, { lat: number; lng: number }>
      location: { lat: number; lng: number }
      location_type: string
      viewport: Record<string, { lat: number; lng: number }>
    }
    place_id: string
    types: string[]
  }[]
  status: string

The closest thing I found to this type in https://github.com/googlemaps/DefinitelyTyped would be google.maps.GeocoderResult.

For the most part, the type looks good, until you start digging into the nested properties. I didn't check the entire type but I noticed that if you follow the type to: google.maps.GeocoderResult.geometry.location instead of returning lat and lng as number it returns them as function which would not work for a simple use case where you would like to parse an API's response.

If that type is not meant to be used like this, then I guess there are no types for API responses which is also not convenient if you want to integrate directly with the APIs using types.

wangela commented 1 year ago

If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.

@nbouvrette Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.