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 JSDoc comment, describing latitude/longitude order for the Point and Bounds types #194

Open
snelsi opened this issue Oct 10, 2023 · 0 comments

Comments

@snelsi
Copy link

snelsi commented Oct 10, 2023

Currently, Point and Bounds types are defined like this:

export type Point = [number, number]

export interface Bounds {
  ne: [number, number]
  sw: [number, number]
}

It provides no hints about what comes first, latitude or longitude.
You need to dive into the docs / examples / source code to find out that latitude is the first param and longitude is the second.

I tried to integrate supercluster with this lib, and faced a problem that it expects those params the other way, longitude first and latitude second. It creates a lot of confusion.

Thankfully, I think there is a super easy solution for this.
Just add a JSDoc comment to the Point type definition, describing the order:

/** @description `[latitude, longitude]` */
export type Point = [number, number]

/** @description `{ ne: [latitude, longitude], sw: [latitude, longitude] }` */
export interface Bounds {
  ne: Point
  sw: Point
}

Your IDE can show those comments as a useful tooltip on hover
image

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

No branches or pull requests

1 participant