Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions types/leaflet/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ export class GeoJSON<P = any, G extends geojson.GeometryObject = geojson.Geometr
geojson: geojson.Feature<G, P> | G,
): geojson.Feature<G, P>;

constructor(geojson?: geojson.GeoJsonObject, options?: GeoJSONOptions<P, G>);
constructor(geojson?: geojson.GeoJsonObject | null, options?: GeoJSONOptions<P, G> | null);
/**
* Adds a GeoJSON object to the layer.
*/
Expand Down Expand Up @@ -2430,12 +2430,12 @@ export class GeoJSON<P = any, G extends geojson.GeometryObject = geojson.Geometr
* an options object.
*/
export function geoJSON<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[],
options?: GeoJSONOptions<P, G>,
geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[] | null,
options?: GeoJSONOptions<P, G> | null,
): GeoJSON<P, G>;
export function geoJson<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[],
options?: GeoJSONOptions<P, G>,
geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[] | null,
options?: GeoJSONOptions<P, G> | null,
): GeoJSON<P, G>;

export type Zoom = boolean | "center";
Expand Down
27 changes: 16 additions & 11 deletions types/leaflet/leaflet-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ mapOptions.scrollWheelZoom = "center";
mapOptions.touchZoom = false;
mapOptions.touchZoom = "center";

let layer: L.Layer;
let layer = new L.Layer();

const htmlElement = document.getElementById("foo");
const htmlElement = document.createElement("div");

layer.addInteractiveTarget(htmlElement);
layer.removeInteractiveTarget(htmlElement);
Expand Down Expand Up @@ -256,10 +256,11 @@ map.panInside(latLng, {
// map.getRenderer

let html: HTMLElement;
let maybeHtml: HTMLElement | undefined;
html = map.createPane("foo");
html = map.createPane("foo", htmlElement);
html = map.getPane("foo");
html = map.getPane(htmlElement);
maybeHtml = map.getPane("foo");
maybeHtml = map.getPane(htmlElement);
html = map.getContainer();

const panes = map.getPanes();
Expand Down Expand Up @@ -417,7 +418,7 @@ imageOverlay.setUrl("https://www.google.ru/images/branding/googlelogo/2x/googlel
imageOverlay.setBounds(imageOverlayBounds);
imageOverlay.setZIndex(1);
imageOverlayBounds = imageOverlay.getBounds();
html = imageOverlay.getElement();
maybeHtml = imageOverlay.getElement();
point = imageOverlay.getCenter();
imageOverlay = imageOverlay.setStyle({ opacity: 90 });

Expand All @@ -444,7 +445,7 @@ svgOverlay.bringToBack();
svgOverlay.setBounds(imageOverlayBounds);
svgOverlay.setZIndex(1);
svgOverlayBounds = svgOverlay.getBounds();
const svgElement: SVGElement = svgOverlay.getElement();
const svgElement: SVGElement | undefined = svgOverlay.getElement();
point = svgOverlay.getCenter();
svgOverlay = svgOverlay.setStyle({ opacity: 90 });

Expand Down Expand Up @@ -475,7 +476,7 @@ videoOverlay.setUrl("https://www.mapbox.com/bites/00188/patricia_nasa.webm");
videoOverlay.setBounds(imageOverlayBounds);
videoOverlay.setZIndex(1);
videoOverlayBounds = videoOverlay.getBounds();
html = videoOverlay.getElement();
maybeHtml = videoOverlay.getElement();
point = videoOverlay.getCenter();
videoOverlay = videoOverlay.setStyle(videoOverlayOptions);

Expand Down Expand Up @@ -660,7 +661,7 @@ class MyMarker extends L.Marker {
const speed = 1000;

if (L.DomUtil.TRANSITION) {
if (this.getElement()) this.getElement().style.setProperty(L.DomUtil.TRANSITION, `all ${speed}ms linear`);
this.getElement()?.style.setProperty(L.DomUtil.TRANSITION, `all ${speed}ms linear`);
if (this._shadow) this._shadow.style.setProperty(L.DomUtil.TRANSITION, `all ${speed}ms linear`);
}
}
Expand Down Expand Up @@ -866,15 +867,15 @@ interface MyProperties {
}

// $ExpectType MyProperties
let polygonFeatureProperties = L.polygon<MyProperties>(simplePolygonLatLngs).feature.properties;
let polygonFeatureProperties = L.polygon<MyProperties>(simplePolygonLatLngs).feature!.properties;
polygonFeatureProperties.testProperty = "test";

// $ExpectType MyProperties
let markerFeatureProperties = L.marker<MyProperties>([1, 2], {
icon: L.icon({
iconUrl: "my-icon.png",
}),
}).feature.properties;
}).feature!.properties;
markerFeatureProperties.testProperty = "test";

let lg = L.layerGroup();
Expand Down Expand Up @@ -946,7 +947,7 @@ export class ExtendedTileLayer extends L.TileLayer {
if (tile instanceof HTMLImageElement && !tile.complete) {
tile.src = L.Util.emptyImageUrl;
L.DomUtil.remove(tile);
this._tiles[i] = undefined;
delete this._tiles[i];
}
}
}
Expand Down Expand Up @@ -989,6 +990,10 @@ circle = new L.Circle(latLng, { radius: 10 });
// @ts-expect-error
circle = new L.Circle(latLng, { radius: "10" });
// @ts-expect-error
circle = new L.Circle(latLng, { radius: undefined });
// @ts-expect-error
circle = new L.Circle(latLng, { radius: null });
// @ts-expect-error
circle = new L.Circle(latLng, {});
// @ts-expect-error
circle = new L.Circle(latLng);
2 changes: 1 addition & 1 deletion types/leaflet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"types": [],
"noEmit": true,
Expand Down