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

Add a more detailed type definition for WebMercatorViewport.getLocationAtPoint() #201

Conversation

sangaline
Copy link
Contributor

@sangaline sangaline commented Feb 24, 2021

The type definition for WebMercatorViewport.getLocationAtPoint() currently uses implicit any typing for lngLat and pos. This can cause TypeScript build errors if noImplicitAny is enabled and skipLibCheck is disabled:

node_modules/@math.gl/web-mercator/src/web-mercator-viewport.d.ts:149:23 - error TS7031:
Binding element 'lngLat' implicitly has an 'any' type.

149   getLocationAtPoint({lngLat, pos}): number[];

node_modules/@math.gl/web-mercator/src/web-mercator-viewport.d.ts:149:31 - error TS7031:
Binding element 'pos' implicitly has an 'any' type.

149   getLocationAtPoint({lngLat, pos}): number[];

This PR is a one-line change to add types for these arguments. The type signature for the function now matches the non-legacy WebMercatorViewport.getMapCenterByLngLatPosition() method (visible a few lines up in the diff). The legacy function simply calls and returns the non-legacy method with the same arguments, so these should have the same type signature:

  // Legacy method name
  getLocationAtPoint({lngLat, pos}) {
    return this.getMapCenterByLngLatPosition({lngLat, pos});
  }

@CLAassistant
Copy link

CLAassistant commented Feb 24, 2021

CLA assistant check
All committers have signed the CLA.

@Pessimistress Pessimistress merged commit 38d36ed into uber-web:master May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants