Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type in google.maps.GeocoderResult #78

Open
nbouvrette opened this issue Mar 19, 2023 · 1 comment
Open

Incorrect type in google.maps.GeocoderResult #78

nbouvrette opened this issue Mar 19, 2023 · 1 comment
Assignees
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@nbouvrette
Copy link

nbouvrette commented Mar 19, 2023

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.

@nbouvrette nbouvrette added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 19, 2023
@wangela
Copy link
Member

wangela commented Mar 19, 2023

If you would like to upvote the priority of this issue, please comment below or react with 👍 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants