I am unable to add event registration for events to Map or Layer for a leaflet plugin. The Evented class from @types/leaflet exposes the events on Map AND Layer, but some of the events I need to add are Map only or Layer only events. Stackblitz for reference
import * as L from 'leaflet';
declare module 'leaflet' {
/**
* Extends built in leaflet map.
*/
interface Map {
on(type: 'pm:globaldrawmodetoggled', fn: (event: { enabled: boolean, shape: string, map: L.Map }) => this, context?: any): this;
}
}
results in the error
Interface 'Map' incorrectly extends interface 'Evented'.
Types of property 'on' are incompatible.
Type '(type: "pm:globaldrawmodetoggled", fn: (event: { enabled: boolean; shape: string; map: Map; }) => this, context?: any) => this' is not assignable to type '{ (type: string, fn: LeafletEventHandlerFn, context?: any): this; (type: "baselayerchange" | "overlayadd" | "overlayremove", fn: LayersControlEventHandlerFn, context?: any): this; (type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this; (type: "zoomlevelschange" | ... 18 more ... | "predrag"...'.
Types of parameters 'fn' and 'fn' are incompatible.
Types of parameters 'event' and 'event' are incompatible.
Type '{ enabled: boolean; shape: string; map: Map; }' is missing the following properties from type 'LeafletEvent': type, target, sourceTarget, propagatedFrom, layer(2430)
Is there something I'm overlooking here, or maybe something I could try to get changed upstream to allow @types/leaflet to be more compatible with additional types provided by plugins?