Javascript 在TypeScript typings.d.ts传单(JS到ts)中的现有类型上添加属性/函数

Javascript 在TypeScript typings.d.ts传单(JS到ts)中的现有类型上添加属性/函数,javascript,angular,typescript,leaflet,Javascript,Angular,Typescript,Leaflet,我正在尝试在传单插件上实现typings(typings.d.ts)。目的是使插件在我的Angular TypeScript项目中可用。 我理解打字的逻辑,但我没有成功地实现它,我的TSLinter继续产生错误。 插件工作正常,但TS错误令人讨厌 类型“typeof Marker”上不存在属性“movingMarker” 类型“Marker”上不存在属性“addStation” 正在使用库的我的代码块: import 'src/assets/js/leaflet-movingMarker'

我正在尝试在传单插件上实现typings(typings.d.ts)。目的是使插件在我的Angular TypeScript项目中可用。 我理解打字的逻辑,但我没有成功地实现它,我的TSLinter继续产生错误。
插件工作正常,但TS错误令人讨厌

  • 类型“typeof Marker”上不存在属性“movingMarker”
  • 类型“Marker”上不存在属性“addStation”

正在使用库的我的代码块:

import 'src/assets/js/leaflet-movingMarker';

...

this.messageIcon = create_icon('message', 40, '#f5af19', 'This is a message');
this.messageMarker = L.Marker.movingMarker([ // << error : Property 'movingMarker' does not exist on type 'typeof Marker'.
   L.latLng([this.a.Lat, this.a.Lng]),
   L.latLng([this.b.Lat, this.b.Lng])
    1000 * 2,
);
this.messageMarker.addStation(1, 1000); // << error : Property 'addStation' does not exist on type 'Marker<any>'.
this.messageMarker.addStation(2, 1000); // error
this.messageMarker.start(); // error
this.messageMarker.options.icon = this.messageIcon;
import * as L from 'leaflet';

declare module 'leaflet' {
    interface MarkerOptions {
        autostart?: boolean;
        loop?: boolean;
    }

    interface Marker {
        movingMarker(latlngs: L.LatLng[], durations: Number[], options?: Object): Marker;
        addStation(pointIndex: number, duration: number): this;
        start(): this;
        isRunning(): this;
        isEnded(): this;
        isStarted(): this;
        isPaused(): this;
        resume(): this;
    }
}
我认为,这个插件的部分是最有问题的:

L.Marker.movingMarker = function (latlngs, duration, options) {
    return new L.Marker.MovingMarker(latlngs, duration, options);
};