Skip to content

Commit 16c5767

Browse files
authored
🤖 Merge PR DefinitelyTyped#74222 [leaflet.vectorgrid] add other allowed tile layer style definitions by @symsmith
1 parent c3b1e88 commit 16c5767

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

‎types/leaflet.vectorgrid/index.d.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as geojson from "geojson";
2-
import geojsonvt = require("geojson-vt");
32
import * as L from "leaflet";
3+
import geojsonvt = require("geojson-vt");
44

55
declare module "leaflet" {
66
interface TileProps {
@@ -74,7 +74,8 @@ declare module "leaflet" {
7474
rendererFactory?: TileFactoryFunction<T>;
7575
/** A data structure holding initial symbolizer definitions for the vector features. */
7676
vectorTileLayerStyles?:
77-
| Record<string, PathOptions>
77+
| Record<string, PathOptions | PathOptions[]>
78+
| Record<string, ((properties: Record<string, string>, zoom: number) => PathOptions | PathOptions[])>
7879
| ((properties: Record<string, string>, zoom: number) => PathOptions);
7980
/** Whether this VectorGrid fires Interactive Layer events. */
8081
interactive?: boolean;

‎types/leaflet.vectorgrid/leaflet.vectorgrid-tests.ts‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import "leaflet.vectorgrid";
21
import * as GJ from "geojson";
32
import * as L from "leaflet";
3+
import "leaflet.vectorgrid";
44

55
const data: GJ.FeatureCollection = {
66
type: "FeatureCollection",
@@ -98,3 +98,49 @@ new L.VectorGrid({
9898
return {};
9999
},
100100
});
101+
102+
// $ExpectType VectorGrid<HTMLCanvasElement | SVGViewElement>
103+
new L.VectorGrid({
104+
...vectorgridOptions,
105+
vectorTileLayerStyles: {
106+
name: {},
107+
},
108+
});
109+
110+
// $ExpectType VectorGrid<HTMLCanvasElement | SVGViewElement>
111+
new L.VectorGrid({
112+
...vectorgridOptions,
113+
vectorTileLayerStyles: {
114+
name: [{}],
115+
},
116+
});
117+
118+
// $ExpectType VectorGrid<HTMLCanvasElement | SVGViewElement>
119+
new L.VectorGrid({
120+
...vectorgridOptions,
121+
vectorTileLayerStyles: {
122+
name: (
123+
// $ExpectType Record<string, string>
124+
_properties,
125+
// $ExpectType number
126+
_zoom,
127+
) => {
128+
return {};
129+
},
130+
},
131+
});
132+
133+
// $ExpectType VectorGrid<HTMLCanvasElement | SVGViewElement>
134+
new L.VectorGrid({
135+
...vectorgridOptions,
136+
vectorTileLayerStyles: {
137+
name: (
138+
// $ExpectType Record<string, string>
139+
_properties,
140+
// $ExpectType number
141+
_zoom,
142+
) => {
143+
return [{}];
144+
},
145+
},
146+
});

0 commit comments

Comments
 (0)