question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

typescript type definition for Leaflet.markercluster

See original GitHub issue

An up to date (free of syntax errors) typescript definition for Leaflet markercluster is needed.

And it would be great if the definition can be included in this repo and specified in the package.json. (See http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html).

Currently registry:dt/leaflet-markercluster#0.4.0+20160919070725 is broken. I did some initial investigation and I believe but could be wrong that:

  • It should be exporting an interface that extends FeatureGroup. A class usually isn’t in a type definition because it is an implementation. Currently there is an error from typescript compiler saying a class doesn’t extend, but implements - which is true. But the problem is that it shouldn’t be a class, but rather an interface definition.
  • FeatureGroup is not a generic

I can look at this more, but I don’t know the API very well so it may take me more time. If someone else has solved this or can get to it before me, I’d appreciate it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
denyocommented, Apr 13, 2017

Hello, I have a similar issue or at least related issue here. I am using

"leaflet": "^1.0.3",
"leaflet.markercluster": "^1.0.4"

and

"@types/leaflet": "^1.0.60",
"@types/leaflet-markercluster": "^1.0.3"

Code completion and everything works perfectly fine. However during compilation of ng serve it fails with

Property 'markerClusterGroup' does not exist on type 'typeof L'.

Any ideas how to solve this?

EDIT I found the solution here: https://github.com/angular/angular-cli/wiki/stories-third-party-lib Make sure to add the types in the src/tsconfig.app.json, NOT the tsconfig.json in your project folder.

"typeRoots": [
  "node_modules/@types"
],
"types": [
  "leaflet",
  "leaflet-markercluster"
]
3reactions
severinbeauvaiscommented, Jul 17, 2018

I’m using

"leaflet": "^1.3.1",
"leaflet.markercluster": "^1.3.0"

and

"@types/leaflet": "^1.2.6",
"@types/leaflet-markercluster": "^1.0.3"

The following worked for me:

import 'leaflet';
import 'leaflet.markercluster';

const L = window['L'];
Read more comments on GitHub >

github_iconTop Results From Across the Web

@types/leaflet.markercluster - npm
@types/leaflet.markercluster. TypeScript icon, indicating that this package has built-in type declarations.
Read more >
@types/leaflet.markercluster | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
MarkerCluster LeafletJS plugin TypeScript definition file creation
marketcluster.ts appears to be just JavaScript code, it does not contain any TypeScript class declaration. You should create a definition file leaflet.
Read more >
@types/react-leaflet-markercluster - npm package | Snyk
TypeScript definitions for react-leaflet-markercluster For more information about how to use this package see README. Latest version published 1 year ago.
Read more >
Leaflet With Markercluster And Typescript - ADocLib
Leaflet.markercluster plugin provides beautiful animated Marker Clustering GitHub releases npm TypeScript definitions on DefinitelyTyped types.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found