diff --git a/types/haversine/index.d.ts b/types/haversine/index.d.ts index 6fed860d8b..97d6292c59 100644 --- a/types/haversine/index.d.ts +++ b/types/haversine/index.d.ts @@ -4,10 +4,28 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace haversine { - interface Coordinate { + interface CoordinateLongNames { longitude: number; latitude: number; } + + interface CoordinateShortNames { + lat: number; + lon: number; + } + + interface LatLonTuple extends Array { + 0: number; + 1: number; + } + + interface GeoJSON { + geometry: { + coordinates: LatLonTuple + } + } + + type coordinate = (CoordinateLongNames | CoordinateShortNames | LatLonTuple | GeoJSON); interface Options { /** @@ -18,6 +36,10 @@ declare namespace haversine { * If passed, will result in library returning boolean value of whether or not the start and end points are within that supplied threshold. Default: null. */ threshold?: number; + /** + * Format of coordinate arguments. + */ + format?: '[lat,lon]' | '[lon,lat]' | '{lon,lat}' | 'geojson' } } @@ -25,8 +47,8 @@ declare namespace haversine { * Determines the great-circle distance between two points on a sphere given their longitudes and latitudes */ declare function haversine( - start: haversine.Coordinate, - end: haversine.Coordinate, + start: coordinate, + end: coordinate, options?: haversine.Options ): number;