Adding 'distance' return field to the 'polylabel' package (#65352)

* Adding polylabel 'distance' return field

This was added to library in June 2020 -- see https://github.com/mapbox/polylabel/pull/61

* Updating version number as well

* Whoops got confused between version number in two different forks of the lib
This commit is contained in:
Jonathan Loesch
2023-06-05 20:48:52 -04:00
committed by GitHub
parent 8791364d47
commit 4eb7404273
2 changed files with 15 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for polylabel 1.0
// Type definitions for polylabel 1.1
// Project: https://github.com/mapbox/polylabel
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -12,6 +12,6 @@
* @example
* var p = polylabel(polygon, 1.0);
*/
declare function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
declare function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[] & {distance: number};
declare namespace polylabel {}
export default polylabel;

View File

@@ -5,3 +5,16 @@ polylabel(polygon);
polylabel(polygon, 1.0);
polylabel(polygon, 1.0, true);
polylabel(polygon, 1.0, false);
// $ExpectType number
polylabel(polygon)[0];
// $ExpectType number
polylabel(polygon)[1];
// $ExpectType number
polylabel(polygon).distance;
const [x, y] = polylabel(polygon);
// $ExpectType number
x;
// $ExpectType number
y;