mapbox / mapbox/mapbox-gl-js

MapEvents originalEvent type issue

Open
#13,566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

### mapbox-gl-js version

v3.15.0

### Expected behavior

The following MapEvents types has a optional `originalEvent` property:
- zoomstart
- zoom
- zoomend
- pitchstart
- pitch
- pitchend

### Actual behavior

The `originalEvent` inaccessible according to typescript.

Reason:
The listed events has a `| void` defined in the type.

Current:
```typescript
"zoomstart": {
originalEvent?: WheelEvent | TouchEvent;
} | void
```
Fixed:
```typescript
"zoomstart": {
originalEvent?: WheelEvent | TouchEvent;
}
```

### Steps to trigger the unexpected behavior

```typescript
const map = new mapboxgl.Map({ container: 'map' })
map.on('zoomstart', (e) => {
console.log(e.originalEvent) // <-- Type error
})
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the MapEvents type definitions for the listed zoom and pitch events and reproduce the TypeScript error with the callback shown in the issue. Update the event typing so the documented originalEvent property is accessible, then run the repository's type checks or relevant tests to confirm the callback compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.