[@types/mapbox__mapbox-gl-geocoder] wrong expected function type for MapboxGeocoder's externalGeocoder property #71080
Unanswered
borntobesso
asked this question in
Issues with a @types package
Replies: 1 comment
-
Thanks for the discussion about "mapbox__mapbox-gl-geocoder", some useful links for everyone: Pinging the DT module owners: @Nosfit, @dmytro-gokun. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue Summary:
The expected function type for the externalGeocoder property in the MapboxGeocoder.GeocoderOptions interface is not accurate. The documentation states the expected function signature as:
(property) MapboxGeocoder.GeocoderOptions.externalGeocoder?: ((searchInput: string, features: GeoJSON.FeatureCollection<GeoJSON.Geometry>) => Promise<GeoJSON.FeatureCollection>) | undefined
This suggests that the function should return a Promise<GeoJSON.FeatureCollection>. However, in practice, the function is expected to return an Array<GeoJSON.Feature<GeoJSON.Geometry>> instead of a GeoJSON.FeatureCollection.
Actual Behavior:
When I write a function that returns a GeoJSON.FeatureCollection as described in the documentation, the Mapbox Geocoder doesn't work correctly. But if I modify the function to return an Array<GeoJSON.Feature<GeoJSON.Geometry>>, the Mapbox Geocoder works as expected.
Expected Behavior:
The documentation and type definition for the externalGeocoder property should be updated to reflect the correct expected return type, which is an Array<GeoJSON.Feature<GeoJSON.Geometry>> instead of a GeoJSON.FeatureCollection.
Proposed Resolution:
Update the type definition for the externalGeocoder property in the MapboxGeocoder.GeocoderOptions interface to the following:
(property) MapboxGeocoder.GeocoderOptions.externalGeocoder?: ((searchInput: string, features: GeoJSON.FeatureCollection<GeoJSON.Geometry>) => Promise<Array<GeoJSON.Feature<GeoJSON.Geometry>>>) | undefined
This will ensure the type definition accurately reflects the actual expected return type for the externalGeocoder function.
Beta Was this translation helpful? Give feedback.
All reactions