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

TypeScript definitions #54

Open
high1 opened this issue Nov 12, 2017 · 4 comments
Open

TypeScript definitions #54

high1 opened this issue Nov 12, 2017 · 4 comments

Comments

@high1
Copy link

high1 commented Nov 12, 2017

Missing type definitions for TypeScript.

@StazriN
Copy link

StazriN commented Jun 21, 2018

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

@gwillz
Copy link

gwillz commented Aug 13, 2018

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.

@silviuburceadev
Copy link

silviuburceadev commented Dec 22, 2020

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.

@nunos7
Copy link

nunos7 commented Mar 31, 2022

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 :(...

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

No branches or pull requests

6 participants