Skip to content

Commit 326a96a

Browse files
authored
turf-nearest-point: maintain point properties in result type (#2866)
1 parent b53f6d1 commit 326a96a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/turf-nearest-point/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Feature, FeatureCollection, Point } from "geojson";
1+
import { Feature, FeatureCollection, GeoJsonProperties, Point } from "geojson";
22
import { Coord, Units } from "@turf/helpers";
33
import { clone } from "@turf/clone";
44
import { distance } from "@turf/distance";
55
import { featureEach } from "@turf/meta";
66

7-
interface NearestPoint extends Feature<Point> {
7+
interface NearestPoint<P extends GeoJsonProperties = GeoJsonProperties>
8+
extends Feature<Point> {
89
properties: {
910
featureIndex: number;
1011
distanceToPoint: number;
11-
[key: string]: any;
12-
};
12+
} & P;
1313
}
1414

1515
/**
@@ -38,13 +38,13 @@ interface NearestPoint extends Feature<Point> {
3838
* var addToMap = [targetPoint, points, nearest];
3939
* nearest.properties['marker-color'] = '#F00';
4040
*/
41-
function nearestPoint(
41+
function nearestPoint<P extends GeoJsonProperties = GeoJsonProperties>(
4242
targetPoint: Coord,
43-
points: FeatureCollection<Point>,
43+
points: FeatureCollection<Point, P>,
4444
options: {
4545
units?: Units;
4646
} = {}
47-
): NearestPoint {
47+
): NearestPoint<P> {
4848
// Input validation
4949
if (!targetPoint) throw new Error("targetPoint is required");
5050
if (!points) throw new Error("points is required");

0 commit comments

Comments
 (0)