googlemaps / js-polyline-codec

Polyline encoding and decoding.
Apache License 2.0
59 stars 10 forks source link

Make LatLngTuple a Tuple instead of an Array #301

Closed debkanchan closed 3 years ago

debkanchan commented 3 years ago

Is your feature request related to a problem? Please describe. LatLngTuple is an alias for number[] which can have n number of values in it instead of being [number, number] tuple with only 2 numbers. Hence it can be used with ... spread operator but cannot be used in places where only 2 positional values of Lat and Long are required.

Example: Using it with firestore GeoPoint like this

class GeoPoint {
//...
constructor(latitude: number, longitude: number);
//...

const location: LatLngTuple = [0, 0];
new GeoPoint(...location); //invalid

will cause the following error error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter

Describe the solution you'd like Make LatLngTuple a proper [number: number] tuple and in encode function let the union type be (number[] | LatLng | LatLngTuple) to keep the fliexibility

Describe alternatives you've considered

const location: LatLngTuple = [0, 0];
new GeoPoint(location[0], location[1]);
github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.8 :tada:

The release is available on:

Your semantic-release bot :package::rocket: