I have a JS library called leaflet which has an existing TypeScript definition file.
I wish to use a plugin which extends some of the objects in leaflet with an extr
This is what I tried and it feels relatively comfortable for me
declare module L {
export class CircleMarkerEx {
constructor(source: CircleMarker);
public bindLabel(name: string, options: any): CircleMarker;
}
export function ex(cm: CircleMarker): CircleMarkerEx;
}
where CircleMarkerEx
and ex
can be defined as
class CircleMarkerExtender extends CircleMarker {
public b() {
return `${this.a()} extended`;
}
}
CircleMarker.prototype = Object.create(CircleMarkerExtender.prototype);
CircleMarker.prototype.constructor = CircleMarker;
export function ex(cm: CircleMarker) {
return cm as CircleMarkerExtender;
}
then
let cm = ex(circle).bindLabel("name", {});
but it is still a little strange