react-leaflet-markercluster icon indicating copy to clipboard operation
react-leaflet-markercluster copied to clipboard

TypeScript definitions

Open high1 opened this issue 6 years ago • 4 comments

Missing type definitions for TypeScript.

high1 avatar Nov 12 '17 21:11 high1

How it looks with type definitions for TypeScript? When will it be supported please? Thanks

StazriN avatar Jun 21 '18 07:06 StazriN

Considering it only inherits MapLayer with no fancy whatever, something like this works:

declare module 'react-leaflet-markercluster' {
    import {MapLayer} from 'react-leaflet'
    export default class MarkerClusterGroup extends MapLayer {}
}

Edit: Don't forget, it's dependent on @types/react-leaflet.

gwillz avatar Aug 13 '18 05:08 gwillz

I am using react-leaflet-markercluster 3.0.0-rc1 and @types/react-leaflet-markercluster 2.0.0 and I get this in the code:

'MarkerClusterGroup' cannot be used as a JSX component. Its instance type 'MarkerClusterGroup' is not a valid JSX element. Type 'MarkerClusterGroup' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more. TS2786

Code is very simple, used the example:

<MarkerClusterGroup>
  <Marker position={[49.8397, 24.0297]} />
  <Marker position={[52.2297, 21.0122]} />
  <Marker position={[51.5074, -0.0901]} />
</MarkerClusterGroup>

The index.d.ts clearly says that the definitions apply to v2.0, can we have something for 3.0.0?

Here is the definition for React Leaflet's FeatureGroup: export declare const FeatureGroup: import("react").ForwardRefExoticComponent<FeatureGroupProps & import("react").RefAttributes<LeafletFeatureGroup<any>>>; So I'm guessing that MarkerClusterGroup is something similar?

p.s. MapLayer is gone from React Leaflet v3 so it isn't as simple as @gwillz posted for v2.

silviuburceadev avatar Dec 22 '20 13:12 silviuburceadev

Hi, what types do you use? I'm using "@types/react-leaflet-markercluster": "^3.0.0", and I have no way to set the events :(...

nunos7 avatar Mar 31 '22 07:03 nunos7