I am currently working on a leaflet plugin that I intend to connect to the global L
object. This plugin adds an object called MyPlugin
to the global L
, which includes various properties and methods accessible via L.MyPlugin
. One of these properties is actually a class named SpecialLayer
. As I create my type declaration file for the plugin, I'm unsure how to incorporate this.
import L from 'leaflet';
import { ConfigOptions } from './types';
import SpecialLayer from './SpecialLayer';
declare module 'leaflet' {
export namespace MyPlugin {
function someFunction(something: string): string;
function anotherFunction(userConfig: Partial<ConfigOptions>): ConfigOptions;
const _config: ConfigOptions;
const _cache: {};
}
}
I am struggling with adding a class alongside these functions and constants, such as making it the typeof SpecialLayer
. I have attempted several methods that did not work. In the export namespace MyPlugin
section:
class SpecialLayer = SpecialLayer; // error: '{' expected.
class SpecialLayer {} // does not bring type definitions from SpecialLayer into namespace?
How can I include the SpecialLayer
within the L.MyPlugin namespace while utilizing all existing TypeScript definitions from the externally defined SpecialLayer
class?