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 incomplete definition `setGlobalOptions` ? #1164

Closed hoetmaaiers closed 2 years ago

hoetmaaiers commented 2 years ago

When using the function map.pm.setGlobalOptions I am obliged to pass snappingOrder and panes.

map.pm.setGlobalOptions({ hideMiddleMarkers: true }); 

Might it be better to update the typing to:

setGlobalOptions(options: Partial<GlobalOptions>): void;

This depend on the exact implementation of course. But if the new options are applied on top of the default ones I see no problem.

Falke-Design commented 2 years ago

What does Partial mean?

The implementation is the same as everywhere in Leaflet. Only the passed options are overwritten and the others are still available / applied

hoetmaaiers commented 2 years ago

Then Partial would make every option optional. https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype

This would allow me to only provide hideMiddleMarkers as an option to map.pm.setGlobalOptions.

Falke-Design commented 2 years ago

@ryan-morris what do you think?

ryan-morris commented 2 years ago

@Falke-Design I agree with the suggestion. it's either that or we need to make all properties on GlobalOptions allow undefined. I think the Partial<GlobalOptions> is a cleaner approach

Falke-Design commented 2 years ago

@ryan-morris Thank you, your help is very useful for me!

Falke-Design commented 2 years ago

@hoetmaaiers can you please check if #1168 works for you