googlemaps / google-maps-services-js

Node.js client library for Google Maps API Web Services
Apache License 2.0
2.89k stars 639 forks source link

TypeScript error in Request interfaces #1210

Open StanislavHT opened 4 months ago

StanislavHT commented 4 months ago

Now request interfaces like DistanceMatrixRequest, GeocodeRequest extends AxiosRequestConfig which has params (type: any).

In my case I just want to omit key from request params because we set key globally, so I defined following interface.

interface IKeyOmittedGeocodeRequest extends Omit<GeocodeRequest, 'params'> {
  params: Omit<Pick<GeocodeRequest, 'params'>, 'key'>;
}

But as GeocodeRequest extends AxiosRequestConfig which has params, TypeScript recognizes params in IKeyOmittedGoecodeRequest from AxiosRequestConfig which is any. And it doesn't recognize request.params.destinations.

image

StanislavHT commented 4 months ago

I think all request interfaces should inherit Omit<Partial<AxiosRequestConfig>, 'params'>

wangela commented 4 months ago

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

@StanislavHT 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.