Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@types/mapbox__mapbox-gl-geocoder] wrong expected function type for MapboxGeocoder's externalGeocoder property #71082

Open
borntobesso opened this issue Nov 4, 2024 Discussed in #71080 · 0 comments

Comments

@borntobesso
Copy link

Discussed in #71080

Originally posted by borntobesso November 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant