visgl / react-map-gl

React friendly API wrapper around MapboxGL JS
http://visgl.github.io/react-map-gl/
Other
7.88k stars 1.36k forks source link

[Bug] Exported `MapGeoJSONFeature` and `MapLayerMouseEvent.features` mismatch for maplibre #2266

Closed KiwiKilian closed 1 year ago

KiwiKilian commented 1 year ago

Description

When using maplibre the type MapGeoJSONFeature is exported from react-map-gl/src/types/common.ts as:

export type MapGeoJSONFeature = GeoJSON.Feature<GeoJSON.Geometry> & {
  layer: any;
  source: string;
  sourceLayer: string;
  state: {[key: string]: any};
};

The MapLayerMouseEvent features MapGeoJSONFeature are typed from maplibre-gl/dist/maplibre-gl.d.ts:

export type MapGeoJSONFeature = GeoJSONFeature & {
    layer: DistributiveOmit<LayerSpecification, "source"> & {
        source: string;
    };
    source: string;
    sourceLayer?: string;
    state: {
        [key: string]: any;
    };
};

Expected Behavior

The types should match. Will this be fixed by #2263?

Steps to Reproduce

https://codesandbox.io/s/react-map-gl-mapgeojsonfeature-h698nj?file=/src/index.tsx:608-636

Environment

Logs

No response

Pessimistress commented 1 year ago

Try v7.1.5.

KiwiKilian commented 1 year ago

Looks good 🙏!