types: extend LeafletEventHandlerFnMap with pm:* events#1659
Open
mvanhorn wants to merge 18 commits into
Open
Conversation
…o#1631) Bumps the dev-dependencies group with 2 updates: [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) and [prosthetic-hand](https://github.com/IvanSanchez/prosthetic-hand). Updates `oxlint` from 1.16.0 to 1.43.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.43.0/npm/oxlint) Updates `prosthetic-hand` from 1.3.1 to 1.4.0 - [Changelog](https://github.com/Leaflet/prosthetic-hand/blob/main/CHANGELOG.md) - [Commits](https://github.com/IvanSanchez/prosthetic-hand/commits) --- updated-dependencies: - dependency-name: oxlint dependency-version: 1.43.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: prosthetic-hand dependency-version: 1.4.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…eoman-io#1634) Bumps the production-dependencies group with 4 updates: [@turf/boolean-contains](https://github.com/Turfjs/turf), [@turf/kinks](https://github.com/Turfjs/turf), [@turf/line-intersect](https://github.com/Turfjs/turf) and [@turf/line-split](https://github.com/Turfjs/turf). Updates `@turf/boolean-contains` from 7.3.3 to 7.3.4 - [Release notes](https://github.com/Turfjs/turf/releases) - [Changelog](https://github.com/Turfjs/turf/blob/master/CHANGELOG.md) - [Commits](Turfjs/turf@v7.3.3...v7.3.4) Updates `@turf/kinks` from 7.3.3 to 7.3.4 - [Release notes](https://github.com/Turfjs/turf/releases) - [Changelog](https://github.com/Turfjs/turf/blob/master/CHANGELOG.md) - [Commits](Turfjs/turf@v7.3.3...v7.3.4) Updates `@turf/line-intersect` from 7.3.3 to 7.3.4 - [Release notes](https://github.com/Turfjs/turf/releases) - [Changelog](https://github.com/Turfjs/turf/blob/master/CHANGELOG.md) - [Commits](Turfjs/turf@v7.3.3...v7.3.4) Updates `@turf/line-split` from 7.3.3 to 7.3.4 - [Release notes](https://github.com/Turfjs/turf/releases) - [Changelog](https://github.com/Turfjs/turf/blob/master/CHANGELOG.md) - [Commits](Turfjs/turf@v7.3.3...v7.3.4) --- updated-dependencies: - dependency-name: "@turf/boolean-contains" dependency-version: 7.3.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production-dependencies - dependency-name: "@turf/kinks" dependency-version: 7.3.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production-dependencies - dependency-name: "@turf/line-intersect" dependency-version: 7.3.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production-dependencies - dependency-name: "@turf/line-split" dependency-version: 7.3.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…o#1633) Bumps the dev-dependencies group with 2 updates: [cypress](https://github.com/cypress-io/cypress) and [esbuild](https://github.com/evanw/esbuild). Updates `cypress` from 15.9.0 to 15.10.0 - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](cypress-io/cypress@v15.9.0...v15.10.0) Updates `esbuild` from 0.27.2 to 0.27.3 - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) - [Commits](evanw/esbuild@v0.27.2...v0.27.3) --- updated-dependencies: - dependency-name: cypress dependency-version: 15.10.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: esbuild dependency-version: 0.27.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [qs](https://github.com/ljharb/qs) from 6.14.1 to 6.14.2. - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](ljharb/qs@v6.14.1...v6.14.2) --- updated-dependencies: - dependency-name: qs dependency-version: 6.14.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…o#1636) Bumps the dev-dependencies group with 2 updates: [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) and [oxfmt](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxfmt). Updates `oxlint` from 1.43.0 to 1.47.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.47.0/npm/oxlint) Updates `oxfmt` from 0.28.0 to 0.32.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxfmt/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxfmt_v0.32.0/npm/oxfmt) --- updated-dependencies: - dependency-name: oxlint dependency-version: 1.47.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: oxfmt dependency-version: 0.32.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…1637) Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 5.30.7 to 5.31.1. - [Release notes](https://github.com/sebhildebrandt/systeminformation/releases) - [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md) - [Commits](sebhildebrandt/systeminformation@v5.30.7...v5.31.1) --- updated-dependencies: - dependency-name: systeminformation dependency-version: 5.31.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [rollup](https://github.com/rollup/rollup) from 4.57.1 to 4.59.0. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](rollup/rollup@v4.57.1...v4.59.0) --- updated-dependencies: - dependency-name: rollup dependency-version: 4.59.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps and [picomatch](https://github.com/micromatch/picomatch). These dependencies needed to be updated together. Updates `picomatch` from 4.0.3 to 4.0.4 - [Release notes](https://github.com/micromatch/picomatch/releases) - [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md) - [Commits](micromatch/picomatch@4.0.3...4.0.4) Updates `picomatch` from 2.3.1 to 2.3.2 - [Release notes](https://github.com/micromatch/picomatch/releases) - [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md) - [Commits](micromatch/picomatch@4.0.3...4.0.4) --- updated-dependencies: - dependency-name: picomatch dependency-version: 4.0.4 dependency-type: indirect - dependency-name: picomatch dependency-version: 2.3.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…eoman-io#1646) All PM event handlers now include `source` and an index signature for custom payload properties via BaseEventPayload intersection, matching the runtime behavior in Events.js where __fire() merges { source } and customPayload into every event. Fixes geoman-io#1111 Co-authored-by: Matt Van Horn <[email protected]>
…7 updates (geoman-io#1640) Bumps the dev-dependencies group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) | `4.0.18` | `4.1.0` | | [cypress](https://github.com/cypress-io/cypress) | `15.10.0` | `15.12.0` | | [esbuild](https://github.com/evanw/esbuild) | `0.27.3` | `0.27.4` | | [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) | `1.47.0` | `1.56.0` | | [oxfmt](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxfmt) | `0.32.0` | `0.41.0` | | [lint-staged](https://github.com/lint-staged/lint-staged) | `16.2.7` | `16.4.0` | Updates `@vitest/coverage-v8` from 4.0.18 to 4.1.0 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.0/packages/coverage-v8) Updates `cypress` from 15.10.0 to 15.12.0 - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](cypress-io/cypress@v15.10.0...v15.12.0) Updates `esbuild` from 0.27.3 to 0.27.4 - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) - [Commits](evanw/esbuild@v0.27.3...v0.27.4) Updates `oxlint` from 1.47.0 to 1.56.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.56.0/npm/oxlint) Updates `oxfmt` from 0.32.0 to 0.41.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxfmt/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxfmt_v0.41.0/npm/oxfmt) Updates `lint-staged` from 16.2.7 to 16.4.0 - [Release notes](https://github.com/lint-staged/lint-staged/releases) - [Changelog](https://github.com/lint-staged/lint-staged/blob/main/CHANGELOG.md) - [Commits](lint-staged/lint-staged@v16.2.7...v16.4.0) Updates `vitest` from 4.0.18 to 4.1.0 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.0/packages/vitest) --- updated-dependencies: - dependency-name: "@vitest/coverage-v8" dependency-version: 4.1.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: cypress dependency-version: 15.12.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: esbuild dependency-version: 0.27.4 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: oxlint dependency-version: 1.56.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: oxfmt dependency-version: 0.41.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: lint-staged dependency-version: 16.4.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: vitest dependency-version: 4.1.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The pm:* events are typed via 'on' / 'once' / 'off' overloads on
the Evented interface, which covers the imperative API:
map.on('pm:edit', (e) => /* e typed correctly */)
But the keyed form (used by react-leaflet's eventHandlers prop and
any other consumer that builds a record literal and passes it to
on(eventMap)) goes through LeafletEventHandlerFnMap, which has a
fixed key set in @types/leaflet -- no string index signature.
That meant <Polyline eventHandlers={{ 'pm:edit': handler }} />
neither type-checked the event name nor the handler payload, and
react-leaflet users had to ship private leaflet.d.ts shims.
This extends the LeafletEventHandlerFnMap interface inside the
existing 'declare module "leaflet"' block with the same handler
types already used by the on/once/off overloads. pm:vertexadded
keeps both shapes (draw-mode VertexAddedEventHandler and
edit-mode VertexAddedEventHandler2) as a union, mirroring the two
existing on() overloads.
Closes geoman-io#1515.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
a6c2d12 to
884e8e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1515.
The
pm:*events are typed today viaon/once/offoverloads on theEventedinterface, which covers the imperative API:But the keyed form -- used by
react-leaflet'seventHandlersprop and anyother consumer that builds a record literal and passes it to
on(eventMap)--flows through
LeafletEventHandlerFnMap, which has a fixed key set in@types/leaflet(no string index signature). That meant:neither type-checked the event name nor the handler payload, and react-leaflet
users had to ship a private
leaflet.d.tsshim that mirrors the pm:* events.The issue thread describes exactly this experience.
Implementation
Extends
LeafletEventHandlerFnMapinside the existingdeclare module 'leaflet'block with the same handler types already usedby the
on/once/offoverloads. No new handler types are introduced;this is purely a record-form mirror of the imperative overloads.
pm:vertexaddedcarries two payload shapes today (PM.VertexAddedEventHandlerin draw mode,
PM.VertexAddedEventHandler2in edit mode) and the file alreadydeclares two
onoverloads for it. The record entry is typed as the union ofboth so the keyed form matches the existing imperative behavior exactly.
leaflet-geoman.d.tsLeafletEventHandlerFnMapaugmentation, +129 linesNo source changes -- this is a
.d.ts-only PR.Verification
Quick sanity check that the augmentation flows into a record literal:
tsc --noEmitaccepts this with the patch applied; without it,'pm:edit'would error as an unknown property of
LeafletEventHandlerFnMapandewould fall back to
any.Notes
on/once/offoverloads are unchanged. Anything thatworked before still works -- this is purely additive type information.
declare module 'leaflet'block thatalready extends
Evented,Map,Path, etc., so consumers don't needany extra imports.
LeafletEventHandlerFnshape or changeany payload types -- the maintainer comment ("we are happy to add
solutions but we are not TypeScript developers") suggested keeping the
scope tight, so this just mirrors what's already there.