How to deal with Leaflet Plugins
CoolGeo2016 opened this issue · 2 comments
CoolGeo2016 commented
Much of leaflet plugins without type declaration file in the DefinitelyTyped repository, such as 'esri-leaflet'.
How can I deal with them,except create declaration file by myself.
Can you give some advice?
haoliangyu commented
TypeScript is definitely typed so you will still need to provide some sort of type declaration.
- If you would like to keep the typed leaflet, you could provide a minimal type declaration for your plugin like:
/// <reference types="leaflet" />
declare namespace L {
// no type definition, just to tell the existence of pluginFunction() at L namespace
export var pluginFunction: any;
}
- or remove the type declaration of leaflet and use it like Javascript
declare var L: any;
Source: Typescript library without tsd file. Cannot instantiate class
haoliangyu commented
Please read my blog Using an untyped Leaflet plugin in your TypeScript project