google-maps-services-js icon indicating copy to clipboard operation
google-maps-services-js copied to clipboard

TypeScript error in Request interfaces

Open StanislavHT opened this issue 1 year ago • 2 comments

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 avatar May 23 '24 15:05 StanislavHT

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

StanislavHT avatar May 23 '24 15:05 StanislavHT

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.

wangela avatar May 23 '24 15:05 wangela