geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

TypeScript getGeomanDrawLayers improvement #865

Closed hstevanoski closed 3 years ago

hstevanoski commented 3 years ago

I think the return type of the getGeomanDrawLayers method should be improved.
Currently, in leaflet-geoman.d.ts, we have the following:

/** Returns all Geoman layers on the map as array. Pass true to get a L.FeatureGroup. */
getGeomanLayers(featureGroup?: boolean): L.FeatureGroup | L.Layer[];
/** Returns all drawn Geoman layers on the map as array. Pass true to get a L.FeatureGroup. */
getGeomanDrawLayers(featureGroup?: boolean): L.FeatureGroup | L.Layer

The issue is that getGeomanDrawLayers doesn't return an array (missing [] after L.Layer), so you have to rely on the getGeomanLayers method to perform array-specific operations (not ideal in more complex scenarios).

Falke-Design commented 3 years ago

Thank you for reporting, this is not the wanted behaviour, we will change it to L.Layer[].

@ryan-morris can you add this please in the next TypeScript PR?

ryan-morris commented 3 years ago

Will do