Skip to content

TypeScript EventHandlers do not support all properties in payloadย #1111

@Falke-Design

Description

@Falke-Design

In the event payload there is always the source and the possibility to add custom properties. Is it possible to extend types and make a base event type with source and custom properties?

TS:

export type GlobalRotateModeToggledEventHandler = (e: {
enabled: boolean;
map: L.Map;
}) => void;

JS where the payload and the custom payload are merged:

__fire(fireLayer, type, payload, source, customPayload = {}) {
payload = merge(payload, customPayload, { source });
L.PM.Utils._fireEvent(fireLayer, type, payload);
},

@ryan-morris maybe you have time to check this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions