diff --git a/types/leaflet.markercluster/index.d.ts b/types/leaflet.markercluster/index.d.ts index e2f317dd46..4bcf268da6 100644 --- a/types/leaflet.markercluster/index.d.ts +++ b/types/leaflet.markercluster/index.d.ts @@ -7,7 +7,7 @@ import * as L from 'leaflet'; declare module 'leaflet' { - interface MarkerCluster extends Marker { + class MarkerCluster extends Marker { /* * Recursively retrieve all child markers of this cluster. */ @@ -117,7 +117,7 @@ declare module 'leaflet' { chunkDelay?: number; } - interface MarkerClusterGroup extends FeatureGroup { + class MarkerClusterGroup extends FeatureGroup { /* * Bulk methods for adding and removing markers and should be favoured over the * single versions when doing bulk addition/removal of markers. diff --git a/types/leaflet.markercluster/leaflet.markercluster-tests.ts b/types/leaflet.markercluster/leaflet.markercluster-tests.ts index aeee213ca5..cc54bb1163 100644 --- a/types/leaflet.markercluster/leaflet.markercluster-tests.ts +++ b/types/leaflet.markercluster/leaflet.markercluster-tests.ts @@ -81,3 +81,34 @@ markerClusterGroup.zoomToShowLayer(marker, () => {}); let hasLayer: boolean; hasLayer = markerClusterGroup.hasLayer(layer); hasLayer = markerClusterGroup.hasLayer(marker); + +// inheritance +const Subclass1 = L.MarkerClusterGroup.extend({ + myFunction() {} +}); +class Subclass2 extends L.MarkerClusterGroup { + myFunction() {} +} +const Subclass3 = L.MarkerCluster.extend({ + myFunction() {} +}); +class Subclass4 extends L.MarkerCluster { + myFunction() {} +} + +const s1 = new Subclass1(); // any +const s2 = new Subclass2(); +const s3 = new Subclass3(); // any +const s4 = new Subclass4([1, 2]); + +// call subclass function +s1.myFunction(); +s2.myFunction(); +s3.myFunction(); +s4.myFunction(); + +// call base class function +s1.refreshClusters(); +s2.refreshClusters(); +s3.getAllChildMarkers(); +s4.getAllChildMarkers();