-
Notifications
You must be signed in to change notification settings - Fork 7
Incorrect type in google.maps.GeocoderResult #78
Description
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: stringThe 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.