My Aurelia project in TypeScript uses Leaflet for mapping. While Leaflet has typings the esri-leaflet plugin does not and is just javascript. How do I use / import the javascript plugin in my TypeScript classes. TIA
Asked
Active
Viewed 644 times
0
-
i think you'd be better served by trying to determine how to import any arbitrary JavaScript library into a TypeScript project and afterward an Aurelia project. the problem (and solution) are unlikely to be specific to esri-leaflet. – john gravois May 23 '17 at 05:02
1 Answers
0
You should extend the type definition for leaflet. Create a new typescript file and add the following.
declare module L {
export let esri:any;
export class Esri {
}
}
import this file after leaflet
if you need to extend other plugins:
declare module L {
//plugins that extend Control comes here
export namespace Control {
export let Navbar: any;
}
// plugins that have control factories come here
export namespace control {
export let navbar: any;
}
//plugins that extend Layer comes here
export namespace Layer {
export let NewLayer: any;
}
// plugins that have layer factories come here
export namespace layer {
export let newLayer: any;
}
//plugins that extend Handler comes here
export namespace Handler {
export let NewHandler: any;
}
// plugins that have handler factories come here
export namespace handler {
export let newHandler: any;
}
}
You can be explicit with the types if you want to.

Jonas Tomanga
- 1,069
- 10
- 19